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:
Then you select the “ExtensionlessUrlHandler-Integrated-4.0 handler:
Select “Request Restrictions”:
Then add PUT and DELETE on the “Verbs” tab:
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:
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?").
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:
Then you select the “ExtensionlessUrlHandler-Integrated-4.0 handler:
Select “Request Restrictions”:
Then add PUT and DELETE on the “Verbs” tab:
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?").
No hay comentarios:
Publicar un comentario