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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:02:33+00:00 2026-06-15T15:02:33+00:00

I have an ASP.NET MVC web application, all the pages in which use a

  • 0

I have an ASP.NET MVC web application, all the pages in which use a single master Layout.cshtml page. Although I usually want to RenderBody(), I have a site shutdown mechanism that can be enabled in my database so I basically want to have a layout page that looks something like:

@if(DbHelper.SiteIsShutDown) {
    <h1>Site is shut down temporarily</h1>
}
else {
    <h1>Welcome to the site</h1>
    @RenderBody()
}

The trouble is that if SiteIsShutDown is true, then RenderBody() doesn’t get called and I get the exception:

The “RenderBody” method has not been called for layout page…

So is there a way I can get round this? I just want to render some output from my layout page, and nothing from my view page.

  • 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-15T15:02:34+00:00Added an answer on June 15, 2026 at 3:02 pm

    In the end I decided to go with something pretty similar to Jerad Rose’s solution, but modified so it just serves up a static file at the root called SiteDisabled.htm, and also modified so that it doesn’t go into an infinite redirect loop when the site is disabled:

    protected void Application_BeginRequest(object sender, EventArgs ea) {
        string siteDisabledFilePath = "/SiteDisabled.htm";
    
        if (CachingAndUtils.IsSiteDisabled && HttpContext.Current.Request.FilePath != siteDisabledFilePath) {
            HttpContext.Current.Response.Redirect(siteDisabledFilePath);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
I have an ASP.NET MVC 3 (Razor) Web Application, with a particular page which
My web application is an Asp.Net MVC pattern. None of the .aspx pages have
I have a rather large ASP.NET MVC web application which uses KnockoutJS extensively throughout.
I have asp.net mvc 4 web application project on my server in IIS Directory.
I have a Asp.net MVC web application, containing mostly text. I want to put
Here's what I'm trying to do. I have an ASP.NET MVC web application, where
I have developed a MVC web application with ASP.NET MVC and im just wondering
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have one question; In my ASP.NET MVC web application have to do certain

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.