0
votes

I have the following configuration in my web.config file. I have a rest web api. I am trying to create a resource by using the PUT method but when I do that I get the following error:

IIS 7.5 Detailed Error - 405.0 - Method Not Allowed

I went through different posts on StackOverflow, but they are of no use. The same configuration is working fine on my other machine.

I don't know what configuration I have missed out, here's my configuration:

<handlers>
    <remove name="WebDAV" />
    <remove name="OPTIONSVerbHandler" />
    <remove name="TRACEVerbHandler" />
    <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" />
    <add name="WebDAV" path="*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="WebDAVModule" resourceType="Unspecified" requireAccess="None" />
</handlers>
1
I suspect WebDAV is conflicting with your Web API controller. You should remove all references to WebDAV and any ISAPI handlers and modules (assuming you're using Integrated Mode).Dai

1 Answers

0
votes

If you're not using it, you need to remove the WebDAV native module:

<system.webServer>
    <modules>
        <remove name="WebDAVModule" />
    </modules>
</system.webServer>

Otherwise it kicks in and won't permit certain verbs unless you're authenticated using Windows Authentication.