This is because HTTP GET and HTTP POST are disable by default in .NET (from version 1.1).
This article (http://support.microsoft.com:80/default.aspx?scid=kb;en-us;819267) explains the situation.
The symptoms are as follows:
- The statuscode of the XMLHTTP call is “undefined”.
- The statustext of the XMLHTTP call is “Internal Server Error”.
- You get the following exception: Request format is unrecognized for URL unexpectedly ending in ‘/MyFunction‘.
In order to fix this issue you will have to enable HTTP POST (and maybe also HTTP GET) by adding a declaration to the web.config. I prefer to add a local web.config along with my web service. Simply put a web.config in the same folder as your .asmx file with the following contents:
<?xml version="1.0"?> <configuration> <appSettings/> <connectionStrings/> <system.web> <webServices> <protocols> <add name="HttpPost"/> </protocols> </webServices> <compilation debug="false"></compilation> </system.web> <system.codedom> </system.codedom> <!-- The system.webServer section is required for running ASP.NET AJAX under Internet Information Services 7.0. It is not necessary for previous version of IIS. --> <system.webServer> </system.webServer> </configuration>
This configuration file allows HTTP POST calls to be executed on all services installed in the same folder. To allo HTTP GET calls, simply add HttpGet to the file as well:
<configuration> <system.web> <webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> </system.web> </configuration>
You could also add the XML to the web site’s web.config, but this will allow all HTTP GET and HTTP POST calls to all services, and you might not want this.