How can I redirect maintenance site in asp.net
asp.net, c#, ihttphandler
Solution
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.
Problem
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"); } } ```