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 8185807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:58:35+00:00 2026-06-07T01:58:35+00:00

How to display a default page like Maintenance page for all the views if

  • 0

How to display a default page like Maintenance page for all the views if a web.config key is set to true?

If the key is false, then show the regular views.

Plz note, I don’t want to repeat the code in each controller and am looking for a common place, like _ViewStart or _Layout page where this can be defined.

Thanks.

  • 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-06-07T01:58:37+00:00Added an answer on June 7, 2026 at 1:58 am

    You could create your own ActionFilterAttribute and base Controller, which gives you access to OnActionExecuting. You could then test if the Web.Config value is set (perhaps loading it into an Application variable when you first start your Web app) and if it is set, setting the Controller and Action attributes to your maintenance page. Then all of your controllers, instead of inheriting from the standard Controller would inherit from your controller instead, except for the Maintenance controller which could still inherit from the normal Controller.

    For instance:

    [RedirectToMaintenancePage]
    public class MyController : Controller
    {
    }
    

    And for a typical controller:

    public class SampleController : MyController
    {
    ... Your actions ...
    }
    

    Then create a class called RedirectToMaintenancePageAttribute.cs:

    public class RedirectToMaintenancePageAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
             If Web.config says to go to Maintenance page then...
             {
                  filterContext.Result = RedirectToRouteResult("route name") // Or some other redirect
                  return;
             }
    
             // else
             base.OnActionExecuting(filterContext);
        }
    }
    

    This is all off the top of my head, but I think it should work, and if it doesn’t hopefully it’ll give you some ideas.

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

Sidebar

Related Questions

When I set the Default Document in IIS to display my Default page (
I'm trying to display the page title (html title) on the default.aspx page of
Hello I would like to display an other splashscreen after the default one, if
I have a HTML page where I have to display a popup (like tool
I am trying to display content of two sequences on web page. First one
i have two popup windows in my Home Page (Default.aspx) like below : apsx
I want to create a sitemap page for Magento that will display all the
I'v used SharePoint:SPGridView control in aspx page to display data as I would like
Suppose my web page has a struture like this: <body> <div id=fee> <div id=fi>
I have Default.aspx and a seperate code file: public partial class _Default : System.Web.UI.Page

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.