在 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");
}
在 web.config:
<appSettings>
<add key="MaintenanceMode" value="true"/>
</appSettings>
<location path="Maintenance.htm">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
当通过 Visual Studio 在本地运行网站时,一切都很好,
但在网络服务器上,我得到了一个用户名/密码登录窗口,
按下后Cancel
显示 401 消息。
此外,登录窗口不接受输入正确的用户名和密码。
我正在使用表单身份验证。
欢迎任何建议。