Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Put the website in Maintenance Mode (Under Construction)

, 27 Dec 2011
Rate this:
Please Sign up or sign in to vote.
Here is the source code for another solution:Global.asax:void Application_BeginRequest(object sender, EventArgs e){ if (ConfigurationManager.AppSettings["MaintenanceMode"] == "true") { if ((ConfigurationManager.AppSettings["ByPassUrl"].Contains( ...

Here is the source code for another solution:

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

from viewing offline page.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mukund Thakker
Technical Lead
India India
Software Developer
MCTS - .NET Framework 4.0, Web Applications
 
Blog : http://thakkermukund.wordpress.com
Twitter@thakkermukund
 
Don't code today, what you can't debug tomorrow!
Everything makes sense in someone's mind
Follow on   Twitter

Comments and Discussions

 
GeneralReason for my vote of 5 good, keep it up. Pinmemberkelvin z2-Jan-12 23:09 
GeneralRe: Thanks Kelvin PinmemberMukund Thakker2-Jan-12 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 27 Dec 2011
Article Copyright 2011 by Mukund Thakker
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid