当消费WebService时,我得到了以下错误:
URL意外以/myMethodName结尾,请求格式无法识别
如何解决这个问题?
当消费WebService时,我得到了以下错误:
URL意外以/myMethodName结尾,请求格式无法识别
如何解决这个问题?
当前回答
在这个网站上找到了一个解决方案
你所需要做的就是在你的web.config中添加以下内容
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
来自微软的更多信息
其他回答
在这个网站上找到了一个解决方案
你所需要做的就是在你的web.config中添加以下内容
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
来自微软的更多信息
确保您禁用了自定义错误。这可以掩盖代码中的原始问题:
改变
<customErrors defaultRedirect="~/Error" mode="On">
to
<customErrors defaultRedirect="~/Error" mode="Off">
确保你使用了正确的方法:Post/Get,正确的内容类型和正确的参数(数据)。
$.ajax({
type: "POST",
url: "/ajax.asmx/GetNews",
data: "{Lang:'tr'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) { generateNews(msg); }
})
在我的情况下,我有一个重载的函数,导致这个异常,一旦我改变了我的第二个函数的名称,它运行正常,猜web服务器不支持函数重载
以我为例,当我从本地PC的Windows 10移动到安装Windows 2012的专用服务器时,出现了这个错误。 解决方案是添加到网络。配置以下行
<webServices>
<protocols>
<add name="Documentation"/>
</protocols>
</webServices>