A reader of my recent ASP.NET Core and Angular 2 book wrote me about a strange error occurred while publishing the OpenGameList Single-Page Application into production upon a Windows Server + IIS powered environment machine.
The published SPA seemed to be working OK at first, but when he logged in as Admin to update an item the command kept failing with the following message:
Error 405 - Methods not Allowed
I did my best to help him to troubleshoot the issue: after a few tests we found out that such error was coming out in response to any attempted PUT and DELETE request, while GET and POST methods were working fine.
Such weird discovery led me to dig through the web looking for a suitable explanation, until I eventually found the cause: it seems like the culprit is the WebDAVModule, which seems to set PUT and DELETE request methods disabled by default. In order to get them to work, we either need to change these defaults or disable it for the whole web application, which was what we did.
Here's what we put in the web.config file to remove it for good:
1 2 3 4 5 |
<system.webServer> <modules runAllManagedModulesForAllRequests="false"> <remove name="WebDAVModule" /> </modules> </system.webServer> |
Despite the rather easy workaround, such an issue is definitely a though one, as it will easily affect most ASP.NET Core Web API and Web Applications when they get deployed on a live environment: that's because the WebDAV module, although not supported by IIS Express, happens to be enabled in most production servers. I guess that a lot of users will stumble upon it sooner or later... I definitely hope that this post will help some of them to overcome the hassle.
thank you my friend.
It happened to me.
Savior. Thanks!
You’re welcome! :)
Savior, indeed! Thank you!
Oh thank god I found this post!!! Thank you! Thank you!!
Thanks to you :) don’t forget to LIKE the page if you found it helpful ^____^
Hola, gracias por la solucion, ahora tengo un problemas mas grande, trabajo con AWS y monto mi api en elastickbeanstalk, por lo que al momento de estar publicada mi API, no tengo una forma de agregar ese esa configuración, ahora la pregunta es si es posible modificar esta configuración con código.
Thanks!!
Thank you very much! Nobody is talking about this issue and it took me nearly a whole day of playing around this behaviour until I found your post!
Thank you for reading! :) If the post has been useful to you, don’t forget to like on FB/Twitter to help other developers find us as well :)
Thank You
Thank you! It works fine, (on ASP.NET Core 3.1)
Your post saved my soul.
You’ve literally saved my life !