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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:02:52+00:00 2026-06-04T23:02:52+00:00

In ASP.NET MVC 3 Razor, you can specify the page title with: @{ ViewBag.Title

  • 0

In ASP.NET MVC 3 Razor, you can specify the page title with:

@{
    ViewBag.Title = "Title";
}

Now, suppose we have a layout page with:

<title>@ViewBag.Title | Website</title>

When ASP goes to render a page, it will need to output some of the layout page HTML, then the view HTML, then the rest of the layout page HTML.

In order to output the first half of the layout page HTML, ASP.NET will need to know the value given to ViewBag.title in the view. Thus, ASP.NET needs to parse the Razor code in the view. However, ASP.NET can’t output the view’s HTML code just yet because it is still outputting the layout page’s HTML code. So does ASP.NET store the HTML output of the view in a buffer? That seems like a bad practice, but I can’t think of any other way to efficiently get the view’s title into the layout page output.

  • 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-04T23:02:53+00:00Added an answer on June 4, 2026 at 11:02 pm

    When ASP goes to render a page, it will need to output some of the layout page HTML, then the view HTML, then the rest of the layout page HTML.

    That’s how web forms are rendered. However due to the issue you describe (along with a few others) mvc renders inside out.

    So the inner view is rendered first to a temporary buffer. Then the layout page. This rendering continues until the outer most layout page is reached when the buffer is then wrote to the response stream and flushed.

    This doesn’t cause any issues 90% of the time (guestimate) however this will cause headaches if you ever need to flush the response early.

    FYI the buffer for the views can be accessed with:

    HtmlHelper.ViewContext.Writer
    

    So to answer your question, yes – it does buffer views.

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

Sidebar

Related Questions

I have an ASP.NET MVC 3 (Razor) Web Application, with a particular page which
I have created HtmlHelper in ASP.NET MVC 4 razor view engine C#. Can I
In Asp.net MVC Razor we can use the _ViewStart.cshtml file to define the default
I am developing an ASP.Net MVC 3 Web application using Razor Views. I have
I am working on asp.net MVC 3 application. I have created a Razor view
I have a ASP.Net MVC app with Razor. I try to access a collection
I have a new ASP.NET MVC 3 project, and MVC and Razor are all
I have the following in my ASP.Net MVC 3 Razor View @foreach (var item
I have a foreach looping through a List of objects in an ASP.NET MVC/Razor
How can i directly access a .cshtml file in ASP.NET MVC using razor view

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.