Home > ASP.Net 3.5 > Put the website in Maintenance Mode (Under Construction)

Put the website in Maintenance Mode (Under Construction)

Global.asax:
void Application_BeginRequest(object sender, EventArgs e)
{
if (ConfigurationManager.AppSettings["MaintenanceMode"] == "true")
{
if ((ConfigurationManager.AppSettings["ByPassUrl"].Contains(
HttpContext.Current.Request.UserHostAddress.ToString())) || (Request.IsLocal))
{
}
else
{
HttpContext.Current.RewritePath("maintenance.aspx");
}
}
}

Also, if you want to make the application available for certain IPs (to test the application from different machines or restrict the usage to them only), you may include their IPs in the web config and add this to your code:

Web.config:

<add key="MaintenanceMode" value="true" />
<add key="ByPassUrl" value="127.0.0.1" />

//Add list of IP addresses to bypass

Advertisements
Categories: ASP.Net 3.5
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: