159

I use WebClient type to upload *.cab files to my server. On the server side, I registered a HTTP handler for *.cab file with the PUT method as below:

 <add name="ResultHandler" path="*.cab" verb="PUT" type="FileUploadApplication.ResultHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode" />

But I always get a "405 method not allowed" error. The response said the allowed methods are as below:

Headers = {Allow: GET, HEAD, OPTIONS, TRACE
Content-Length: 1293
Content-Type: text/html
Date: Fri, 27 May 2011 02:08:18 GMT
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET}

Even if I explicitly allow the PUT method in the IIS Request Filtering for my web application, the same error still occurs.

I suspect this is a IIS related issue. I'm hoping someone could shed some light on this for me.

1
  • Any reason you include the X-Powered in your header and not remove it ? If you don't use it, you might consider hiding it, as some people search for this tag to target it (ie GoDaddy and some rent-able hosts use this by default for example) Nov 2, 2022 at 20:09

27 Answers 27

292

Often this error is caused by the WebDAV module that try to handle this kind of requests. An easy solution is to remove it from modules and from handlers of the system.webServer section just inside your web.config file. Here a configuration example:

<system.webServer>
    <modules>
        <remove name="WebDAVModule" />
    </modules>
    <handlers>
        <remove name="WebDAV" />
    </handlers>
</system.webServer>
4
  • 5
    Using the following MS article, I added the remove tag to handlers, but it still did not work. Thanks to your answer I see I also needed to add it to the modules section. Much appreciated. Here is the article: asp.net/web-api/overview/testing-and-debugging/… Mar 17, 2015 at 14:28
  • I've tried that but doesn't work for me. I'm still getting the error 405 - Method not allowed. Note that I'm using IIS Express and the error somehow only occurs on PUT but works for GET, POST AND DELETE.
    – Thierry
    Jul 15, 2019 at 21:33
  • I removed the entire WebDAV feature from IIS, since I wasn't actively using it anyway. Kinda stupid that it interferes with normal websites. Saved hours.
    – Suncat2000
    Nov 30, 2022 at 21:13
  • Can confirm, the remove from modules for me: Go to your site in IIS Click "Modules" Remove WebDAVModule Restart site (might not be needed) Apr 3 at 23:36
60

I enabled the Failed Request Tracing, and got the following info:

 <EventData>
  <Data Name="ContextId">{00000000-0000-0000-0F00-0080000000FA}</Data>
  <Data Name="ModuleName">WebDAVModule</Data>
  <Data Name="Notification">16</Data>
  <Data Name="HttpStatus">405</Data>
  <Data Name="HttpReason">Method Not Allowed</Data>
  <Data Name="HttpSubStatus">0</Data>
  <Data Name="ErrorCode">0</Data>
  <Data Name="ConfigExceptionInfo"></Data>
 </EventData>

So, I uninstalled the WebDAVModule from my IIS, everything is fine now~

The IIS tracing feature is very helpful.

3
  • 3
    Thanks for your answer ! After 2 days of research, the only working solution I found to avoid "405 Method Not Allowed" was to define the CORS headers in the Application_BeginRequest method, as mentioned in this answer stackoverflow.com/a/14631068/827168. But your answer is better than all other because it helps spot the problem instead of applying some random patch :)
    – pomeh
    Oct 15, 2014 at 8:54
  • 1
    @Demodave Check here:technet.microsoft.com/en-us/library/cc731223%28v=ws.10%29.aspx Nov 26, 2015 at 1:59
  • 1
    Note, you should also go into the Handler Mappings and delete WebDAV from there, or else you'll get the error message Handler "WebDAV" has a bad module "WebDAVModule" in its module list. Apr 11, 2017 at 14:31
42

I tried most of the answers and unfortunately, none of them worked in completion.

Here is what worked for me. There are 3 things to do to the site you want PUT for (select the site) :

  1. Open WebDav Authoring Rules and then select Disable WebDAV option present on the right bar.

  2. Select Modules, find the WebDAV Module and remove it.

  3. Select HandlerMapping, find the WebDAVHandler and remove it.

Restart IIS.

4
  • This Works! Don't know if all 3 steps can be done by editing web.config file, but this made it easy using only the IIS Management Console. Just note that there are 3 HandlerMapping entries starting with WebDAV* - I removed all 3 and life was good.
    – SlimsGhost
    Jun 3, 2015 at 2:26
  • 2
    I tried uninstalling WebDav and didn't work. Then I followed all three steps above and PUT started working.
    – rareyesdev
    Nov 5, 2015 at 4:37
  • 1
    Steps 2 and 3 can be applied to a virtual directory without affecting the rest of the site.
    – Tonatio
    Apr 10, 2018 at 13:17
  • Step 1 was already "done" on my IIS. I followed steps 2 and 3, and it worked like a charm! Thank you!
    – Helvio
    Oct 23, 2018 at 18:10
33

Taken from here and it worked for me:

  1. Go to IIS Manager.

  2. Click on your app.

  3. Go to "Handler Mappings".

  4. In the feature list, double click on "WebDAV".

  5. Click on "Request Restrictions".

  6. In the tab "Verbs" select "All verbs" .

  7. Press OK.

1
  • 3
    This helped me, but I'll clarify with my experience. 2. (Web Service) app. 3. double click the Handler Mappings icon in the center panel.
    – Gary
    Feb 24, 2017 at 0:20
28

Best to just remove the unused WebDAV feature. Go to Programs and Features => Turn Windows Features On or Off and disable WebDAV Publishing under

Internet Information Services => World Wide Web Services => Common HTTP Features

enter image description here

0
27

I had this problem with WebDAV when hosting a MVC4 WebApi Project. I got around it by adding this line to the web.config:

<handlers>
  <remove name="WebDAV" />
  <add name="WebDAV" path="*" verb="*" modules="WebDAVModule"
      resourceType="Unspecified" requireAccess="None" />
</handlers>

As explained here: http://evolutionarydeveloper.blogspot.co.uk/2012/07/method-not-allowed-405-on-iis7-website.html

1
  • Best solution for someone who actually needs WebDAV. Whether anyone needs WebDAV is a separate discussion. Feb 26, 2018 at 18:23
19

Removing the WebDAV-module should be sufficient. Just change your Web.config:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="WebDAVModule" />
0
12

I was using Angular 8 and was .NET core API. I add the following in my service web.config file. That resolve my error.

<system.webServer>
  <modules runAllManagedModulesForAllRequests="false">
    <remove name="WebDAVModule" />
  </modules>
</system.webServer>
0
12

Here is what worked for me:

Open up IIS and click on your Site.

  1. Double Click on the Modules
  2. Right Click on WebDavPublishing and remove.
  3. Restart running WebSite.
0
10

I had the same problem, with a RESTful API running on aspnet core.

I didn't want to uninstall the WebDAV, and I tried most of the remedies described above. I tried to set the verbs="*" both on the site and on the server itself, but without success.

What did the trick for me was the following:

IIS Manager -> Sites -> MySite -> HandlerMappings -> aspNetCore -> Edit

-> Request Restrictions -> Access -> None (it was Script).

After that everything worked, even if I replaced the original WebDAV options.

3
  • Confirmed with .NET 3.0 Blazor deploy to IIS Feb 13, 2021 at 14:03
  • Confirmed with .NET 7 Blazor deploy to IIS. BLESS YOU! THANK YOU!
    – Carthax
    Oct 18, 2023 at 16:20
  • thank you, the only thing that worked for me .NET 8.0.
    – Wowo Ot
    Mar 4 at 9:01
7

Another important module that needs reconfiguring before PUT and DELETE will work is the options verb

<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="OPTIONSVerbHandler" />
<remove name="WebDAV" />
<add name="OPTIONSVerbHandler" path="*" verb="*" modules="ProtocolSupportModule" resourceType="Unspecified" requireAccess="Script" />
</handlers>

Also see this post: https://stackoverflow.com/a/22018750/9376681

6

For whatever reason, marking WebDAVModule as "remove" in my web.config wasn't enough to fix the problem in my case.

I've found another approach that did solve the problem. If you're in the same boat, try this:

  1. In the IIS Manager, select the application that needs to support PUT.
  2. In the Features View, find WebDAV Authoring Rules. Double-click it, or select Open Feature from the context menu (right-click).
  3. In the Actions pane, find and click on WebDAV Settings....
  4. In the WebDAV Settings, find Request Filtering Behavior, and under that, find Allow Verb Filtering. Set Allow Verb Filtering to False.
  5. In the Actions pane, click Apply.

This prevents WebDAV from rejecting verbs that it doesn't support, thus allowing a PUT to flow through to your RESTful handler unmolested.

0
5

Another tip from me. I have used PHP + IIS, and the Handler Mappings for PHP did not have the PUT verb.

Go to IIS Manager->Your site->Handler Mappings->PHPxx_via_FastCGI->Request Restrictions->Verbs, then add PUT.

That's it!

1
  • 2
    This is the answer php users need. Mar 29, 2018 at 13:52
4

I had the same issues with PUT, PATCH and DELETE but didn't have anything with WebDav installed. Resolution 1 in this article finally helped me: http://support.microsoft.com/kb/942051

0
4

for asp.net core 5

IIS-> Sites -> MySite -> HandlerMappings -> aspNetCore -> Request Restrictions -> Access -> None (it was Script).

1
  • only this helped me, but I don't know if there are any other consequences with switching to none.
    – knile
    Nov 3, 2021 at 2:19
3

For Windows server 2012 -> Go to Server manager -> Remove Roles and Features -> Server Roles -> Web Server (IIS) -> Web Server -> Common HTTP Features -> Uncheck WebDAV Publishing and remove it -> Restart server.

2

For me this error wouldn't go away and allow PUT methods, whatever i did.. uninstalled webdav, put configuration in web.config to remove webdav from handlers and modules, and set up PUT as an allowed verb on the request filters on iis.. and ensure iis handler mappings handling the request had PUT configured..

My problem was eventually due to bad installation of ASP.NET 4.5 Extensions. Removed everything related to asp.net from server roles and features. restarted. readded the roles and restarted. everything worked with above config.

--- The below will make PUT be accepted, but will send it to the wrong handler. --ignore the below

finally, adding PUT verb as allowed verb on TRACE handler mapping on iis worked.. since i had enabled failed error tracing, and this verb was not allowing the verb.

last time i had the same problem on another server's IIS, it was due to a missing '/' at the end of the URL since it was using a default handler without using the default document probably and now i realize that.. so check IIS handler mappings if nothing else helps.

2

I had this problem but nothing related to WebDAV was the issue. In my case, the client was sending a POST to www.myServer.com/api/chart. This call should be handled by the "ExtensionlessUrlHanlder-Integrated-4.0", however, somehow a local file structure was created in my server directory "...\Server\api\chart\". This meant that the "StaticFile" handler was being called instead. Deleting those local files finally solved the problem.

2

I have a same problem for PUT and DELETE request in IIS10 for asp.net core 5.

I just added below lines in web.config and problem is resolve.

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

You can do solve by other way from IIS also.

In IIS, select the application

Add rules to allow HTTP verbs in Request Filtering (But this alone doesn't work).
Go to "Modules", then select the "WebDAV Publishing" module and remove it.
Go to "Handler Mappings", then select the "WebDAV" and remove it.
in cmd run IISRESET
1

This is my solution, alhamdulillah it worked.

  1. Open Notepad as Administrator.
  2. Open this file %windir%\system32\inetsrv\config\applicationhost.config
  3. Press Ctrl-F to find word "handlers accessPolicy"
  4. Add word "DELETE" after word "GET,HEAD,POST".
  5. The sentence will become <add name="PHP_via_FastCGI" path="*.php" verb="GET,HEAD,POST,DELETE"
  6. The word "PHP_via_FastCGI" can have alternate word such as "PHP_via_FastCGI1" or "PHP_via_FastCGI2".
  7. Save file.

Reference: https://learn.microsoft.com/en-US/troubleshoot/iis/http-error-405-website

1

If you are only developing on your machine, using IIS to run your application and you are not going to use WebDAV then just go to Control Panel > Add or Remove Windows features and disable WebDAV

Control Panel > Add or Remove Windows features and disable WebDAV

1

In my case, I was using PHP with IIS. I had to update handler mapping for php-8.2.2.

Go to IIS Manager -> [Your site] -> Handler Mappings -> php-8.2.2 -> Request Restrictions.

Then add PUT and DELETE if it's not available under verb tab.

enter image description here

0

If IIS app pool is running under classic mode, make sure you have the following in your web.config

<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />

    <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" modules="IsapiModule" scriptProcessor="c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" />
0

In my case I had relocated Web Deploy to another port, which was also the IIS port (not 80). I didn't realize at first, but even though there were no errors running both under the same port, seems Web Deploy was most likely responding first instead of IIS for some reason, causing this error. I just moved my IIS binding to another port and all is well. ;)

0

To prevent WebDav from getting enabled at all, remove the following entry from the ApplicationHost.config: <add name="WebDAVModule" />

The entry is located in the modules section.

Exact location of the config: C:\Windows\System32\inetsrv\config\applicationHost.config

0

In case anyone still using ASP classic needs to solve the method not allowed trouble for ASP, you also need to re-register the ASP classic handler for telling it to handle additional verbs. By default, it only handles GET, HEAD and POST.

<system.webServer>

  <!-- other stuff ... -->

  <modules>
    <remove name="WebDAVModule" />
  </modules>
  <handlers>
    <remove name="WebDAV" />
    <remove name="ASPClassic" />
    <add name="ASPClassic" path="*.asp" verb="GET,HEAD,POST,PUT,DELETE,PATCH" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="File" />
  </handlers>
</system.webServer>
0

In order to remove WebDAV module and handler using appcmd you can use this:

appcmd uninstall module WebDAVModule
appcmd clear config -section:system.webServer/handlers -"[name='WebDAV']"

This can also be use in a release pipeline if needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.