GET,POST,PUT,DELETE - 404 Error - how to hack

If you bought a new pc like I did and forgot you made some config changes than you are in for a 404 / 405 Error surprise.
Long story short is you need to make just a few tweeks to make it work:

1. Go here for some wuick documentation: http://www.iis.net/learn/extensions/introduction-to-iis-express/iis-express-faq and look for: Q: How do I enable verbs like PUT/DELETE for my web application?

2. In your config file the one that is holding your REST api put this:


<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV" />
      <remove name="ExtensionlessUrl-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrl-Integrated-4.0" />
      <add name="ExtensionlessUrl-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>

I am mentioning that you should be extra careful with the ExtensionlessUrl-ISAPI-4.0_32bit, ExtensionlessUrlHandler-ISAPI-4.0_64bit, ExtensionlessUrl-Integrated-4.0 naming convention and to be shure you are removing and adding the right stuff take a look in your %userprofile%\documents\iisexpress\config\applicationhost.config and here look for something like abovementioned(ExtensionlessUrl...). 

After this use either Postman or Fiddler to test the api.

Comentarii

Postări populare de pe acest blog

DevExpress Theme Changer ...

RpiCar

5Inch HDMI LCD for RPI 800x480