Request format is unrecognized for URL unexpectedly ending in
Found a solution on this website
All you need is to add the following to your web.config
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
More info from Microsoft
Despite 90% of all the information I found (while trying to find a solution to this error) telling me to add the HttpGet
and HttpPost
to the configuration, that did not work for me... and didn't make sense to me anyway.
My application is running on lots of servers (30+) and I've never had to add this configuration for any of them. Either the version of the application running under .NET 2.0 or .NET 4.0.
The solution for me was to re-register ASP.NET against IIS.
I used the following command line to achieve this...
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Make sure you're using right method: Post/Get, right content type and right parameters (data).
$.ajax({
type: "POST",
url: "/ajax.asmx/GetNews",
data: "{Lang:'tr'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) { generateNews(msg); }
})
Superb.
Case 2 - where the same issue can arrise) in my case the problem was due to the following line:
<webServices>
<protocols>
<remove name="Documentation"/>
</protocols>
</webServices>
It works well in server as calls are made directly to the webservice function - however will fail if you run the service directly from .Net in the debug environment and want to test running the function manually.