Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6386381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:01:11+00:00 2026-05-25T03:01:11+00:00

I would like to use a configuration in the .config file like this: <appSettings>

  • 0

I would like to use a configuration in the .config file like this:

<appSettings>
  <add key="SiteIsActive" value="false"/>
  <add key="SiteNonActive_RedirectTo" value="UnderMaintainance.aspx"/>
</appSettings>

So that, when the setting is set to the false value, the system automatically redirects EVERY REQUEST to the maintainance page.

I tried to do this in this way: using Global.asax’s Application_BeginRequest:

protected void Application_BeginRequest(object sender, EventArgs e) {
  if ((bool)System.Configuration.ConfigurationManager.AppSettings["SiteIsActive"])
    if (this.Request.Path.IndexOf(
       System.Configuration.ConfigurationManager.AppSettings["SiteNonActive_RedirectTo"]) == -1)
      this.Response.Redirect(
      System.Configuration.ConfigurationManager.AppSettings["SiteNonActive_RedirectTo"]);
}

Basically it works, but when redirecting in this way, firefox will show me the page WITHOUT any image or style applied… it’s strange, I look at the page source downloaded by the browser and everything is there!

Is this the right way to achieve my objective?
Do I do anything wrong?

Thankyou

PS: Internet Explorer does not behave like firefox, it shows me the redirected page correctly.

PS2: You guys correctly posted me that a feature called App_Offline is available. Well, I would like not using it for one reason: I would like to use my maintainance page not only to show one status, but more statuses, for example:

1) Maintainance

<appSettings>
  <add key="SiteIsActive" value="false"/>
  <add key="SiteNonActive_RedirectTo" value="UnderMaintainance.aspx?S=Maintainance"/>
</appSettings>

2) Under construction

<appSettings>
  <add key="SiteIsActive" value="false"/>
  <add key="SiteNonActive_RedirectTo" value="UnderMaintainance.aspx?S=UnderConstr"/>
</appSettings>

3) Temporary inactivity

<appSettings>
  <add key="SiteIsActive" value="false"/>
  <add key="SiteNonActive_RedirectTo" value="UnderMaintainance.aspx?S=TempInact"/>
</appSettings>

App_Offline does not offer me this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:01:11+00:00Added an answer on May 25, 2026 at 3:01 am

    There’s a much simpler way to do this and it uses a special page called App_Offline.htm.

    For more information:

    App_Offline.htm – by Scott Guthrie

    You might also want to read the follow up by Scott about a gotcha with IE6:

    App_Offline.htm and working around the “IE Friendly Errors” feature

    When not in use just rename it to something like App_offline.disabled then when you need to do maintenance rename it back to App_Offline.htm again.

    A further justification for this approach is that if your “maintenance” includes deploying the site or editing your web.config, your UnderMaintainance.aspx page may fail to execute because your site will be in a state of flux whilst it is being uploaded. Or, you may have made a mistake and overwritten these “maintenance” values in your web.config.

    App_Offline.htm is great because it means you can really mess up your deployment and no-one will know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like store some configuration data in a config file. Here's a sample
I'm learning how to use System.Configuration in .NET and would like to know if
I would like to have an xml config file as follows: <?xml version=1.0 encoding=utf-8
I would like to override the use of the standard app.config by passing a
I have a configuration class that I would like to use for a variety
I am using AdoNetAppender (SQL server) in my asp.net application and would like use
I would like to use a language that I am familiar with - Java,
I would like to use something like CLR Profiles on .Net 2.0 to see
I would like to use as and is as members of an enumeration. I
I would like to use a component that exposes the datasource property, but instead

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.