Click here to Skip to main content
12,241,499 members (53,111 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

6K views
4 bookmarked
Posted

Put the website in Maintenance Mode (Under Construction)

, 27 Dec 2011 CPOL
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)

Share

About the Author

Mukund Thakker
Technical Lead
India India
Tech Lead
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

You may also be interested in...

Comments and Discussions

 
GeneralReason for my vote of 5 good, keep it up. Pin
kelvin z3-Jan-12 0:09
memberkelvin z3-Jan-12 0:09 
GeneralRe: Thanks Kelvin Pin
Mukund Thakker3-Jan-12 0:14
memberMukund Thakker3-Jan-12 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 27 Dec 2011
Article Copyright 2011 by Mukund Thakker
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid