嗨专家我有问题
当我在本地计算机上尝试我的Web服务时,它可以正常工作
但在我上传并在托管服务器上运行Windows Server 2008 r2 asp.net 4.0
我收到类似这样的错误请求格式无法识别的URL意外地以/ setmylocation结尾
我试过这些解决方案
<system.webServer>
<handlers>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<configuration>
<system.web>
<webservices>
<protocols>
<add name="HttpGet"></add>
<add name="HttpPost"></add>
</protocols>
</webservices>
</system.web>
</configuration>
and here is my client side code
$.ajax({
type: "POST",
url: "locations.asmx/setmylocation",
data: "{proid: '" + proid + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var urloc = response.d;
if (urloc[0].LATITUDE == '') {
initializemap(14.001424154457723, 121.1032415625, 7);
} else {
initializemap(urloc[0].LATITUDE, urloc[0].LONGITUDE, 10);
}
},
failure: function (response) {
alert(response.d);
}
});
我尝试了一切,但问题仍然存在,希望得到问题的答案
谢谢
上面的图片显示其他网络服务电话很好
和elmah.axd的错误
System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/setmylocation'.
at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
答案 0 :(得分:0)
在我的情况下,我不相信所有其他对Web服务的调用都很好,除了setmylocation所以我怀疑它是否是安装asp.net的问题和web.config中缺少配置所以我所做的是在我的浏览器示例上执行Web服务是sample.com/webservice.asmx/setmylocation?id=1然后它向我显示错误
所以如果有人看过这个并且你遇到了同样的问题,我希望它可以帮到你
答案 1 :(得分:0)
.NET连接的Web服务支持HTTP GET,HTTP POST和SOAP协议。默认情况下,在.NET Framework 1.0中,启用了所有三个协议。默认情况下,在.NET Framework 1.1中,HTTP GET和HTTP POST都被禁用。这是出于安全原因。
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="HttpPostLocalhost"/>
<!-- Documentation enables the documentation/test pages -->
<add name="Documentation"/>
</protocols>