Enable Http PUT requests on .NET MVC

前端 未结 3 1101
渐次进展
渐次进展 2020-12-06 05:38

I\'m working on an MVC application. On my original draft of the service I had this method in one of my controllers:

    [AcceptVerbs(HttpVerbs.Post)]
    [Ac         


        
相关标签:
3条回答
  • 2020-12-06 06:04

    After much fruitless searching and blind alleys involving WebDAV I found the answer on another SO family site :)

    https://serverfault.com/questions/93424/how-to-enable-put-and-delete-in-iis7

    0 讨论(0)
  • 2020-12-06 06:08

    I had to remove the WebDav Module completely a stated in this blog post

    <configuration>
      <system.webServer>
        <handlers>
          <remove name="WebDAV" />
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
          <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
          <add name="ExtensionlessUrlHandler-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="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
        <modules>
          <remove name="WebDAVModule" />
        </modules>
      </system.webServer>
    </configuration>
    
    0 讨论(0)
  • 2020-12-06 06:14

    The configuration that worked for us was the following.

        <system.webServer>
        <modules runAllManagedModulesForAllRequests="false">
            <remove name="UrlRoutingModule" />
            <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" preCondition="" />
        </modules>
        <handlers>
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,POST,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
    </system.webServer>
    

    This is specific to extension-less URLs.

    BTW the general recommendation is to set runAllManagedModulesForAllRequests = false.

    0 讨论(0)
提交回复
热议问题