【发布时间】:2014-01-09 02:53:24
【问题描述】:
各位专家,我有问题
当我在本地机器上尝试我的网络服务时,它工作正常
但是在我上传它并在托管服务器上运行 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);
}
});
我尝试了所有方法,但问题仍然存在,希望得到问题的答案
谢谢
上图显示其他web服务调用就好了
还有来自 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)
【问题讨论】:
-
我想补充一点,另外 2 个对 Web 服务的调用运行顺利
-
我放弃了 Web 服务功能,只传递了经纬度槽查询字符串,我发现它更容易
-
我和我的愚蠢,我忘了创建必要的存储过程,被 Web 服务访问终于让它工作了
标签: asp.net web-services