0

在 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 消息。
此外,登录窗口不接受输入正确的用户名和密码。
我正在使用表单身份验证。

欢迎任何建议。

4

2 回答 2

0

我只是想提醒任何搜索此错误的人,它可能是由 web.config 中的各种错误引起的

这个 web.config 是为我解决问题的 web.config 的精髓

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <authentication>
                <anonymousAuthentication userName="" />
            </authentication>
        </security>
    </system.webServer>
</configuration>
于 2014-02-26T22:37:19.967 回答
0

Maintenance.htm将文件更改为ASPX格式解决了这个问题。

于 2012-05-19T20:40:01.323 回答