Webservice仅在远程中返回内部错误500

时间:2017-09-05 11:13:22

标签: c# asp.net angularjs ajax web-services

我尝试了Fuxiang编写的网络服务+ ajax调用。我创建了aspx页面和服务(.asmx)并将其托管在IIS中的服务器中。当我在本地服务器上运行它时,代码工作正常。

当我从远程计算机上调用相同内容时,会出现内部500错误。为什么会这样?当我尝试使用angular而不是jquery ajax时也会发生同样的情况。有什么工作?

错误

  

无法加载资源:服务器响应状态为500   (内部服务器错误)无法识别URL的请求格式   意外地以' / HelloWorld'。

结束

以下是代码:

ASPX

 <script>
        //no paras to call
        $(document).ready(function () {

            $.ajax({
                type: "POST",
                contentType: "application/text",
                url: "Test_WebService.asmx/HelloWorld",
                data: {},
                dataType: 'text',
                error: function (err) {
                    $('#content').html(err);
                },
                success: function (result) {
                    $('#content').html(result);
                    //  alert(result);
                }
            });

            $('#loading').ajaxStart(function () {
                $(this).show();
            }).ajaxStop(function () {
                $(this).hide();
            });
        });

    </script>


<body>
    <form id="form1" runat="server">
        <div id="content">
        </div>
        <div id="loading">
            service is handling,please wait......
        </div>
    </form>
</body>

asmx

 [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class Test_WebService : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            System.Threading.Thread.Sleep(2000);
            return "Hello World";
        }
    }

更新

我在网络配置中添加了以下内容,但尚未进行更改:

 <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>

我已经在网络服务器上注册了asp版本,但它仍无法正常工作

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regii‌​s -i

0 个答案:

没有答案
相关问题