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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:44:03+00:00 2026-06-05T18:44:03+00:00

In Asp.net MVC Razor we can use the _ViewStart.cshtml file to define the default

  • 0

In Asp.net MVC Razor we can use the _ViewStart.cshtml file to define the default layout for our views. That is fine, but why did we loose the web.config setting that was available with web forms engine in system.web > pages.masterPageFile setting?

Why is that important? Because web.config allow automatic environment transformations.

Manual solution

Of course we can put the default layout name in either appSettings and refer to that in the _ViewStart.cshtml or if we have application specific configuration section add additional property which makes things a bit more clear and polished…

But is there any other way that doesn’t include code?

Asp.net MVC team should add the layoutFile configuration setting to system.web.webPages.razor > pages element, shouldn’t they?

The main question is

Am I missing something that is built-in and I don’t know about? Something that requires no code at all similar to WebForms engine?

  • 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-05T18:44:05+00:00Added an answer on June 5, 2026 at 6:44 pm

    Asp.net MVC team should add the layoutFile configuration setting to
    system.web.webPages.razor > pages element, shouldn’t they?

    Feel free to open a ticket on the MS Connect site.

    But while waiting for your ticket to be analyzed by the development teams and probably added in a future version of the ASP.NET MVC framework and the WebPages you could always do the following in your _ViewStart.cshtml:

    @{
        Layout = ConfigurationManager.AppSettings["Layout"];
    }
    

    and then define the layout in your web.config file:

    <appSettings>
        <add key="Layout" value="~/Views/Shared/_Layout.cshtml" />
        ...
    </appSettings>
    

    Another possibility is to write a custom razor view engine in which you set the layout dynamically.

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

Sidebar

Related Questions

How can i directly access a .cshtml file in ASP.NET MVC using razor view
Using ASP.NET MVC can be used the view engine Razor. Razor let you use
I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
Is there an attribute that I can use with ASP.NET MVC 3 to prevent
I'm creating a mobile webpage in ASP.NET MVC 3, razor views but they appear
Working on an ASP.NET MVC 3 (Razor) application, that's mainly concerned with UGC (user
The Razor view engine in ASP.NET MVC supports @helper to define little helper methods.
I'd like to use the Razor View Engine outside of ASP.NET MVC to generate
I have an intersting question. I'm going to use Razor in my asp.net mvc
Im looking to use MVCMailer to send emails using asp.net mvc 3 with razor.

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.