0

I am running a Web API app fine locally. When I deploy it to Windows Server 2012 I can GET fine - but when I try and PUT I get a 405.

I have seen many articles on this - but none of them help.

All I want to do is add something to the Web.Config (on a per app level) that enables PUT. Why is this so hard?

Example post: ASP.NET Web API - PUT & DELETE Verbs Not Allowed - IIS 8

What I added to web config:

<system.web>
<webServices>
  <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
  </protocols>
</webServices>
</system.web>


<system.webserver>
<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
    <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE" />
    <add name="Access-Control-Allow-Headers" value="Content-Type" />
  </customHeaders>
</httpProtocol>
<modules runAllManagedModulesForAllRequests="false">
  <remove name="WebDAVModule" />
</modules>

<validation validateIntegratedModeConfiguration="false" />
<handlers>
  <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" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webserver>

I still get a 405.

How can I get PUT to work? thx.

Community
  • 1
  • 1
niico
  • 11,206
  • 23
  • 78
  • 161

2 Answers2

0

I finally got it to work by uninstalling WebDAV from the server entirely.

niico
  • 11,206
  • 23
  • 78
  • 161
0

No need to uninstall you have removed WebDAVModule but you missed to remove the WebDEV handler in handlers section like this <handlers><remove name="WebDAV"/></handlers>

Suresh
  • 96
  • 4