Posts
203
Comments
1116
Trackbacks
51
Resolve 404 in IIS Express for PUT and DELETE Verbs

IIS Express is a new web server that replaces the old Visual Studio web server (aka Cassini).  IIS Express provides a number of benefits which you can read about here and they key aspect is that it is IIS. However, that’s not to say that there aren’t any gotchas. One of the things that I ran into recently was that I was getting a 404 when trying to use the PUT and DELETE verbs (which are commonly used in RESTful services).  The reason this is happening is because these verbs are not enabled in the mappings for the handlers by default.

To enable this is the full version of IIS, it is a relatively straight forward task using the IIS Admin tool. First you go to the Handler Mappings:

handlerMappings

 

Then you select the “ExtensionlessUrlHandler-Integrated-4.0 handler:

handlerMappingsListView

 

Select “Request Restrictions”:

editManagedHandler

 

Then add PUT and DELETE on the “Verbs” tab:

requestRestrictions

 

Although the IIS Manager GUI makes this easy when using the full version of IIS, you don’t have the benefit of this GUI when working with IIS Express. But IIS Express *is* IIS so you can configure just about anything. The first thing you need to do is to find the IIS Express Configuration file. This is located in: C:\Users\<YourUserName>\Documents\IISExpress\config\applicationhost.config. Near the bottom of the file, you find the <handlers> section at this path: /configuration/location/system.webServer/handlers. Next, do a Find (Ctrl-F) for “ExtensionlessUrl-Integrated-4.0”. The final step is to add PUT and DELETE to the verb attribute:

<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

At this point, you should be good to go!

UPDATE 8/14/2011: Some people have reported that they had to change their applicationhost.config file inside of the "C:\Program Files (x86)\IIS Express\config" directory (which does *not* match the documentation incidentally). The IIS team updated the documentation at the end of July (about 2 months after I originally posted this) here: http://learn.iis.net/page.aspx/901/iis-express-faq/ (just look for the section called "Q: How do I enable verbs like PUT/DELETE for my web application?").

posted on Saturday, May 28, 2011 12:33 AM Print
Comments
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Song Li
5/28/2011 9:56 AM
Cool! Steve. This is a good stuff.

Any idea on how to set up HTTPs with IIS Express, so we can use HTTPs in the Visual Studio?
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Steve
5/29/2011 10:56 PM
@Song - check out this post: http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Tomas Jansson
5/30/2011 1:31 PM
Hey Steve, I tried your "fix" for IIS Express but I'm still getting a 404 when doing a PUT or DELETE. Do you have any idea what the problem could be. It works fine when running the regular IIS.
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Steve
5/30/2011 1:54 PM
@Tomas - This can also be caused by WebDAV conflicts as well but not sure about that one since you're saying regular IIS 7 is working fine for you. But I'd at least check for that.
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Tomas Jansson
5/30/2011 4:10 PM
@Steve, thank you for your response. What do you mean with WebDAV conflict? If WebDAV is handling requests to ".*"? That shouldn't be the case for me since the WebDAV handlers row is commented out. If I find a solution to the problem I'll write it here.
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Tomas Jansson
5/30/2011 4:35 PM
@Steve, sorry for all the confusion. Everything works fine if you update the right config file. I was updating the global appicationhost.config under "program files/...", and then my guess is that my local one overrided my changes. Updating the one under "My Documents" made it work. Great post!
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
sandhi
3/6/2012 5:24 AM
great post! thanks
Gravatar
# Mr
Jon-Paul LeClair
10/17/2012 10:42 AM
Thank you! You saved me from going bald via pulling my hair out! ;)
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Tam
1/6/2013 8:18 AM
Great post, I have been scratching my head on this issue.
Thanks you have saved the remain scanty hair.
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Raees
6/6/2013 6:00 AM
Hi Steve

I have a very similar issue and tried your solution but that didnt worked beside this I even posted this on stackoverflow but still no reponse can you help me out on this

http://stackoverflow.com/questions/16939795/url-routing-does-not-work-on-windows-ec2-instance
Gravatar
# re: Resolve 404 in IIS Express for PUT and DELETE Verbs
Dave
12/15/2013 5:38 PM
This solution doesn't work for me, either. Over and over again... MS articles with sample code that doesn't work. So frustrating!

Post Comment

Title *
Name *
Email
Comment *  
 

View Steve Michelotti's profile on LinkedIn

profile for Steve Michelotti at Stack Overflow, Q&A for professional and enthusiast programmers




Google My Blog

Tag Cloud