'Request format is unrecognized for URL unexpectedly ending
hi experts i am having a problem
when i try my web service on a local machine it works fine
but after i uploaded it and run on a hosted server windows server 2008 r2 asp.net 4.0
i get an error like this Request format is unrecognized for URL unexpectedly ending in /setmylocation
i tried these solutions
<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);
}
});
i tried everything but the problem persist hoping to get an answer to the problem
thank you
the picture above shows that other web service calls are just fine
and the error from 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)
Solution 1:[1]
in my case i was in disbelief that all other call to the web service are fine except for the setmylocation so i doubt if it is a problem in the installation of asp.net and the lack of configuration in the web.config so what i did is execute the web service on my browser sample is sample.com/webservice.asmx/setmylocation?id=1 then it showed me the error
so if anybody read this and you are experiencing the same problem i hope it can help you
Solution 2:[2]
The .NET-connected Web services support HTTP GET, HTTP POST and SOAP protocols. By default, in .NET Framework 1.0, all three protocols are enabled. By default, in .NET Framework 1.1, HTTP GET and HTTP POST are both disabled. This is for security reasons.
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="HttpPostLocalhost"/>
<!-- Documentation enables the documentation/test pages -->
<add name="Documentation"/>
</protocols>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | angelogogo |
Solution 2 | Raj kumar |