Recently , I was delivering a project for a client , and usually what I do is , I prepare CI/CD pipelines , I test the project and I deliver it .
That worked fine , but this time , the client wants the project to be hosted on his own virtual machine , no problem with that let me do it ,it will take 15 min and later I can go jogging or maybe watch an episode of Gotham and see what will happen to Bruce! .
I published the project to a folder , launched IIS ,added a new site and hosted it ,good , let me test !
I tested the create and get methods ,they worked , and the lesson that I learned in my earlier job is that I need to test everything ,not just 1 or 2 methods but everything !
And boom ! the delete and put methods don’t work ! what’s going on !
I mean they work in Visual studio ?! they work in app service on azure !
What’s going on and what the heck is this !
” IIS 10.0 Detailed Error – 405.0 – Method Not Allowed ”
it’s Friday 5 PM and this happens .. “the difference between the past and the present that , I used to freak out but now I smile and say : Oh yeah , something new to learn and share !”
So , I said to my self : right now I have 3 goals :
1- Fix this no matter what, so it’s works and the client can start testing
2- know why this happened and fix it if it needs to be fixed again.
3-share this .
So ,I started the search and if you are looking to quick fix all you have to do now is to insert those lines to web.config under system.webServer
<modules runAllManagedModulesForAllRequests="false"> <remove name="WebDAVModule" /> </modules>
PS : You may need to recycle the app pool or restart IIS for this change to take effect.
Now it’s time to understand why this happened ,the first tought that came to my mind is WebDav can cause IIS to block the Delete and the Put calls ,and if there is no WebDav there is no problem and no block .
What is WebDAV?
WebDAV is short for Web Distributed Authoring and Versioning, and it is an open-standard extension to the HTTP protocol that enables file management over the Internet. In addition to the usual file system-like operations (copy, move, delete, etc), WebDAV adds a flexible property mechanism (based on name/value pairs) and resource locking. WebDAV is a critical component in Microsoft’s web publishing story, used by the WebDAV redirector, Web Folders, SMS/SCCM, and many other components.
Anonymous PROPFINDs are allowed for file listings, but file uploads and WebDAV-based GET requests require an authenticated user. This is a change from IIS 6.0, where anonymous WebDAV file uploads/downloads could be enabled by opening up your security. In WebDAV for IIS 7.0 and above we changed this behavior so that all WebDAV activity would require authentication, but we allow for the use of anonymous PROPFINDs for backward-compatibility with some WebDAV clients. (More specifically, the PUT, MKCOL, PROPPATCH, COPY, MOVE, DELETE, and WebDAV-based GET requests all require authentication.)
If you need more informations you can read from : link
The Fix
After understanding what is WebDav now it’s time to see the fix and how can be done .
1-Deleting WebDAV :
If there is no need for you to use WebDav in general , you can remove it from the system , if you are using windows 10 you can go to “Turn Windows Features On or Off” and uncheck it
In Windows Server you need to go to removing features in server manager .
2- A Quick Fix :
The fix can be done by adding to the web.config:
<modules runAllManagedModulesForAllRequests="false"> <remove name="WebDAVModule" /> </modules>
hope this was helpful 🙂