405 Method Not Allowed using ASP.NET Web API

I have been using the ASP.NET Web API recently on a project and this has been working well together with Backbone.js as the front end framework. I have been using PUT for updating the model and POST for adding to the model.

Everything is going well until I deployed the application on a production server. I got the error when trying to perform a PUT request to the server from the front-end. The error was “405 Method not allowed”.

The reason for this is two parts; one the production server has WebDav installed and this has caused conflicts with ASP.NET Web API and two by default the handler was not allowing the PUT verb.

The solution was to remove the WebDav handler and WebDav module from web.config and change the ExtensionlessUrl handler verb attribute.

1
2
3
4
5
6
7
8
9
10
11
12
<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
   
  </system.webServer>

IIS Wont start error 13 data is invalid

I got the following error when trying to figure out why I couldn’t start IIS 7 on Windows Server 2008 R2.    I tried to start the World Wide Web Publishing Service but its dependency Windows Activation Service wouldn’t start.   I got the following error in the Event Log:

The Windows Process Activation Service service terminated with the following error:
The data is invalid.

After doing some research, I found a good article here.   But I still had the issue, it turned out that I had a valid applicationHost.config file but my C:\Windows\system32\inetsrv\config\schema\NetFx40_IIS_schema_update.xml file was corrupt and had invalid XML.   So I was able to recover the XML file from the C:\inetput\history\schema folder.  Fewl!   Run all the services again and had no problems.

References:

http://www.gringod.com/2008/08/15/when-iis-wont-start-error-13/

http://www.gringod.com/2008/08/15/when-iis-wont-start-error-13/”

Manually removing a windows service

I was working on a small project which involved building a .NET WorkFlow library and a windows service that invokes the WF library to perform a number of sequence activities.   After building the application I also had to build the installer so that I could install the service automatically on the production server.

The thing I missed was to put a custom action in the installer to remove the service.   So, when I uninstalled the application on the production server the service still existed.
Easiest way to remove a service is to open regedt32 and navigate to this path:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

Find the service you are looking for and delete it.

I did attempt to use the command from the command prompt “sc delete <service_name>” but this failed to remove it.

References:

http://stackoverflow.com/questions/197876/how-do-i-uninstall-a-windows-service-if-the-files-does-not-exist-anymore