Thursday, 12 July 2012

Method Not Allowed 405 on IIS7 Website eg PUT, DELETE etc

If you are working with a .net MVC4 WebApi project that needs to provide CRUD capabilities then your the standard Http Methods your site will need to accept are GET, POST, PUT, DELETE.

I had trouble getting my site to accept PUT and DELETE methods when hosting my site locally with IIS7. I am hosting the application under its own website, this lets me change the settings for the particular site using the IIS7 interface. Here are the steps I took to correct the problem:

Begin in IIS7 by highlighting your website, then choosing Handler Mappings from the available options:

Then select WebDAV from the list of Mappings.

Click Request Restrictions.

Then switch to the Verbs tab and highlight All Verbs.

Restart the application in IIS and hey presto! PUT and DELETE enabled (as well as all HTTP methods). If you want to more conservative about which methods are supported then use the option beneath All Verbs.This results in the changes to your Web.config. Inside your <system.web> section goes this snippet: (You don't actually have to add this - IIS7 will have added this itself)

  <remove name="WebDAV" />
  <add name="WebDAV" path="*" verb="*" modules="WebDAVModule" resourceType="Unspecified" requireAccess="None" />

Hope this will help someone out!

P.s. I found WFetch to be quite a useful tool in debugging http requests.



  2. Fixed it for me. Thanks!

  3. Thanks, the screenshots really helped!

  4. Thanks - the screenshots were tremendously useful.

  5. This is not the best way. See here:

  6. I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy.
    video and blog marketing

  7. Thank u so much ... I need it :) it works for me after a lot of search.

  8. Great help ! thanks for sharing.

  9. Worked like a charm!! Also pls mention the side effects of doing this change(if any) in IIS production server. How safe it is?

  10. Hi,

    Thanks for sharing a very interesting article about Method Not Allowed 405 on IIS7 Website eg PUT, DELETE etc. This is very useful information for online blog review readers. Keep it up such a nice posting like this.

    Web Design Company Bangalore

  11. You are a very good soul! Thank you.