NEWS

Tuesday, July 5, 2011

Put the website in Maintenance Mode (Under Construction)

First, you need to add a key/value to your web.config file, so you can turn the maintenance mode ON or OFF.



 
Then put this code block in the Application_BeginRequest of the Global.asax


void Application_BeginRequest(object sender, EventArgs e)


{

if (ConfigurationManager.AppSettings["MaintenanceMode"] == "true")

{

if (!Request.IsLocal)

{

HttpContext.Current.RewritePath("maintenance.aspx");

}

}

}
 
Now if you set the "MaintenanceMode" key in the config to true, all the requests from the remote clients will be redirected to the maintenance.aspx page but the requests from local client will be served normally.

No comments:

Post a Comment