dnnsoftware / Dnn.Platform

DNN (formerly DotNetNuke) is the leading open source web content management platform (CMS) in the Microsoft ecosystem.
https://dnncommunity.org/
MIT License
1.02k stars 749 forks source link

[Enhancement]: Add Remove WebDAV to web config (By Default) #6027

Closed Mostafa-Moafi closed 4 months ago

Mostafa-Moafi commented 4 months ago

Is there an existing issue for this?

Description of problem

We can't use develop API with DELETE or PUT Verb in our module because there isn't <remove name="WebDAVModule" /> in web config

Description of solution

Just enough to add <remove name="WebDAVModule" /> to configuration/system.webServer/modules node in web config but we should check if the <remove name="WebDAVModule" /> element exists.

Description of alternatives considered

No response

Anything else?

No response

Do you be plan to contribute code for this enhancement?

Would you be interested in sponsoring this enhancement?

Code of Conduct

valadas commented 4 months ago

I don't think DNN should itself remove WebDAV IMO. If an extension does not work with WebDAV enabled then I think the extension itself should modify the web.config

jeremy-farrance commented 4 months ago

I like this idea. We do this as a post-deploy step on every DNN site just because its so hard to diagnose when it crops up as an issue. Its a prevention that can save a LOT of time while having zero downside(s).

mitchelsellers commented 4 months ago

There are a number of third-party modules that require/use webdav and a forceful removal of this by DNN Platform would for sure break installations. I would tend to agree with @valadas here.

@dnnsoftware/approvers any other thoughts?

Mostafa-Moafi commented 4 months ago

I don't think DNN should itself remove WebDAV IMO. If an extension does not work with WebDAV enabled then I think the extension itself should modify the web.config

On some servers, the WebDAV module is preventing the DELETE requests and in such cases, the API won't work (the delete functionality).

I think We should change the web.config as explained in the post below and the solution with the most votes.

https://stackoverflow.com/questions/9854602/asp-net-web-api-405-http-verb-used-to-access-this-page-is-not-allowed-how

Also, I Implemented this topic in my module

https://github.com/Mostafa-Moafi/DnnReactModule/blob/f6cf8ce4879de2dc887ffdab01376be0a40ceae2/Utilities/ConfigurationModule.cs

jeremy-farrance commented 4 months ago

@Mostafa-Moafi - since this is easily fixable once discovered and - as pointed out above - it would break existing modules (that use WebDAV) unnecessarily, this proposed enhancement seems like it won't be considered.

As an alternative, maybe propose a solution that provides a warning somehow/somewhere so that when DNN is installed on a server with WebDAV already in place, the situation is surfaced at the Host (or Admin) level. This seems to be about the best we can hope for. This would have been tremendously helpful to me a few times in the last 8 years or so. I am used to it now, but the first time I encountered this it burned a significant amount of time learning and getting to the root cause.

Although maybe the idea has some merit as a change for v10?

donker commented 4 months ago

Sorry, I only see this now. Yes, it is annoying that IIS somehow assumes you want WebDAV and captures these verbs. In my module I add the necessary web.config addition to ensure it is switched off. This is, IMHO, best practice. So if you have an extension that needs these verbs, add the config change script.

jeremy-farrance commented 4 months ago

The topic (problem and fix) are discussed in some detail here. https://github.com/2sic/2sxc/issues/2205

It has always bugged me that this WebDAV bug exists and it rudely "handles" and does not pass things on to Extensionless-URL handler. And there is no way I know of to manage the order of the handlers.

donker commented 4 months ago

And there is no way I know of to manage the order of the handlers.

In your web.config change/install script you can specify where the Remove WebDAV gets inserted if that is what you mean.