ASP.NET Web Services and jQuery/AJAX, Part 2

In my last post, I described how easy jQuery makes it to call an ASP.NET Web Service via AJAX.

Currently, I'm developing on Windows XP (SP2), Resharper 4 (running inside Visual Studio 2008), and using the Visual Studio Web Server.  We deploy to Windows 2003 R2/IIS6.  When I pushed the code described in my last post to the development server to test it out there, the web service call kept failing with an HTTP Status of 500 (internal error).  This basically means something went wrong on the server.

This type of error situation drives me crazy, as in most cases it is a configuration error:  something different between the platform you are developing on and the platform you are deploying to.

After adding a bunch of logging code and some poking and prying, I determined that the web service was indeed working on the server and that authentication was NOT the problem.  The problem turns out that I had forgotten to allow HTTP POST as a protocol for invoking the Web Service.  The trick to allowing HTTP POST is to put this XML

<webServices>
  <protocols>
    <add name="HttpPost" />
  </protocols>
</webServices>
into your Web.config file in the system.web section.

Moral of the Story:  If your development platform is exactly the same as your deployment platform, you can avoid a lot of these problems