設置網站正在維護狀態提醒,訪問該域名下的所以網頁,都提示“本站正在維護,請稍後再訪問”
首先在App_Code添加類“HttpModule.cs”
namespace WebApplication2.App_Code
{
public class BreakModule : IHttpModule
{
public void Dispose() { }
public void Init(HttpApplication application)
{
application.BeginRequest += new EventHandler(application_BeginRequest);
}
void application_BeginRequest(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
application.CompleteRequest();
application.Context.Response.Write("xxxxxx");
}
}
}
修改web.config
找到<httpModules>節點
添加
<add name="BreakModule" type="WebApplication2.App_Code.BreakModule"/>