How can I redirect maintenance site in asp.net

We have a ASP.NET website in .NET which is running successfully in production. we have frequently maintain our server on a particular downtime. Hence, We need a feature to redirect all request to Site Under maintenance web page at downtime. I've accomplished this task with Custom Handler but my customer isn't happy with that solution. Please suggest some alternate solution.

My Custom Handler code as follows

Added Under web.config

    <system.webServer>
        <modules>
          <add name="CustomModule" type="CustomModule"/>
       </modules>
  </system.webserver>

Added Under Http Handler

public class CustomModule : IHttpModule
    {
        // In the Init function, register for HttpApplication 
        // events by adding your handlers.
        public void Init(HttpApplication application)
        {

            application.EndRequest +=
                (new EventHandler(this.Application_EndRequest));
        }
}

Redirect code goes here

private void Application_EndRequest(Object source, EventArgs e)
        {

            if (fileExtension.Equals(".aspx") == true && filePath.Contains("Contact.aspx") == false)
            {
                context.Response.Redirect("Contact.aspx");
            }
        }

Just use app_offline.htm , explained here and here.

If you want to keep the site down for a specific time period (or to some other external event, etc.) then you could run a (scheduled) script on the server to create or remove the app_offline.htm file when needed.


App_Offline.html will do this.

Read about App_Offline.html here.


如果无法将代码部署到生产服务器,那么如何使用计划任务批处理文件(或自定义程序)按计划部署和删除App_Offline.html文件?

链接地址: http://www.djcxy.com/p/15732.html

上一篇: 使用nodejs将来自远程服务器的http请求重定向到本地服务器

下一篇: 如何在asp.net中重定向维护站点