At global.aspx:
void Application_BeginRequest(object sender, EventArgs e)
{
if (ConfigurationManager.AppSettings["MaintenanceMode"] == "true")
if (!Request.IsLocal)
if (Request.CurrentExecutionFilePathExtension == ".aspx")
HttpContext.Current.RewritePath("Maintenance.htm");
}
At web.config:
<appSettings>
<add key="MaintenanceMode" value="true"/>
</appSettings>
<location path="Maintenance.htm">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
When running the web site locally via Visual Studio everything is fine,
but at the web server I’m getting a Username/Password login window,
which after pressing Cancel shows me the 401 message.
Also, entering the right Username and Password aren’t accepted by the login window.
I’m using forms authentication.
Any advice will be welcome.
Changing the
Maintenance.htmfile to anASPXformat solved the problem.