ASP.NET Handle PUT/DELETE verbs

This applies to ASP.NET in general but also Web API.

How can we handle PUT/DELETE verbs without enabling RAMMFAR (RunAllManagedModulesForAllRequests).

I can’t configure the handler mapping within IIS as my site is hosted on an Azure Web Role and any changes I make will not be persisted.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

@Alexander’s answer put me on the right track. Had to add the following to get DELETE/PUT handled by ASP.NET:

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

Method 2

FWIW, we have modified the MVC/Web API project templates to allow all the common HTTP verbs using exactly the mechanism above. The change will be available in the next official drop (which will be RTM). That will it work by default.

Method 3

Already tried to allow the verbs in System.WebServer section in web.config?

Something like this:

<System.WebServer>
     <handlers>
        <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        <add name="ExtensionlessUrlHandler-Integrated-4.0" 
        path="*." 
        verb="GET,HEAD,POST,DEBUG,PUT,DELETE" 
        modules="IsapiModule" 
        scriptProcessor="C:WindowsMicrosoft.NETFramework64v4.0.30319aspnet_isapi.dll" 
        resourceType="Unspecified" 
        requireAccess="Script" 
        preCondition="classicMode,runtimeVersionv4.0,bitness64" 
        responseBufferLimit="0" />
    </handlers>
</System.WebServer>


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x