问题
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.
回答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>
回答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.
回答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:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll"
resourceType="Unspecified"
requireAccess="Script"
preCondition="classicMode,runtimeVersionv4.0,bitness64"
responseBufferLimit="0" />
</handlers>
</System.WebServer>
来源:https://stackoverflow.com/questions/11155528/asp-net-handle-put-delete-verbs