[GH-ISSUE #7] Error 404 when trying to open the acme challenge url II #9

Closed
opened 2026-02-26 21:31:05 +03:00 by kerem · 1 comment
Owner

Originally created by @petrnejedly on GitHub (Jan 17, 2018).
Original GitHub issue: https://github.com/ridercz/AutoACME/issues/7

Hi,

I have a Windows 2016 server running dozens of websites, many of them still using the .NET 2.0 framework. In some cases, the server side Url Redirecting (http(s)://www.site.eu/.well-known/acme-challenge/something ==> http://localhost/AutoACME/something) works just fine. But in other cases, the attempt to call an url like http(s)://www.site.eu/.well-known/acme-challenge/something ends up with the error 404 Not Found. I was trying to investigate why and it looks like this part of Web.Config file causes the problem:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
  </modules>
</system.webServer>

I need this to be set to true so url adresses without any extension (e.g. http(s)://www.site.eu/product-name) can be handled by the .Net Framework (2.0). Internally, these websites use Global.asax and Application_BeginRequest to handle "non-existing" urls.

Is there anything I can do to keep using <modules runAllManagedModulesForAllRequests="true"> and still be able to use the server side Url Redirecting and AutoACME?

Regards, Petr

Originally created by @petrnejedly on GitHub (Jan 17, 2018). Original GitHub issue: https://github.com/ridercz/AutoACME/issues/7 Hi, I have a Windows 2016 server running dozens of websites, many of them still using the .NET 2.0 framework. In some cases, the server side Url Redirecting (```http(s)://www.site.eu/.well-known/acme-challenge/something``` ==> ```http://localhost/AutoACME/something```) works just fine. But in other cases, the attempt to call an url like ```http(s)://www.site.eu/.well-known/acme-challenge/something``` ends up with the error 404 Not Found. I was trying to investigate why and it looks like this part of Web.Config file causes the problem: ``` <system.webServer> <modules runAllManagedModulesForAllRequests="true"> </modules> </system.webServer> ``` I need this to be set to ```true``` so url adresses without any extension (e.g. ```http(s)://www.site.eu/product-name```) can be handled by the .Net Framework (2.0). Internally, these websites use ```Global.asax``` and ```Application_BeginRequest``` to handle "non-existing" urls. Is there anything I can do to keep using ```<modules runAllManagedModulesForAllRequests="true">``` and still be able to use the server side Url Redirecting and AutoACME? Regards, Petr
kerem closed this issue 2026-02-26 21:31:06 +03:00
Author
Owner

@ridercz commented on GitHub (Jan 19, 2018):

Internally, these websites use Global.asax and Application_BeginRequest to handle "non-existing" urls.

That's the cause of the problem. Applications aren't supposed to do that in BeginRequest phase. It's too early and causes various problems including inability to do proper authentication, caching etc. And URL rewriting, which is used by AutoACME.

You have to change your application. The simple way is to modify the code in the BeginRequest event handler to ignore any request which starts with ./well-known/. The right way is to move the code to some more fitting event, like PostMapRequestHandler or PreRequestHandlerExecute.

<!-- gh-comment-id:358929773 --> @ridercz commented on GitHub (Jan 19, 2018): > Internally, these websites use `Global.asax` and `Application_BeginRequest` to handle "non-existing" urls. That's the cause of the problem. Applications aren't supposed to do that in `BeginRequest` phase. It's too early and causes various problems including inability to do proper authentication, caching etc. And URL rewriting, which is used by AutoACME. You have to change your application. The simple way is to modify the code in the `BeginRequest` event handler to ignore any request which starts with `./well-known/`. The right way is to move the code to some more fitting event, like `PostMapRequestHandler` or `PreRequestHandlerExecute`.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AutoACME#9
No description provided.