1

I have an MVC4 application with two areas, "Reports" and "Admin". I want views in these areas to use the same _Layout that is used throughout the entire application (~/Shared/_Layout.cshtml). When I build the application and hit it on my dev workstation, both areas render correctly. However, when I publish it to Server 2008 R2 (running IIS 7.5), none of the views in the Admin area have the _Layout. I've switched browsers, tried both on the web server and hitting it from another system in the domain, clearing the cache....nothing has worked. Anyone know why this is happening?

AJ.
  • 16,368
  • 20
  • 95
  • 150

1 Answers1

1

In a current project I have an area and in this area's Views folder there's a file called _ViewStart.cshtml. Its Layout property points to the application level _Layout.cshtml file that's within the ApplicationName/Views/Shared folder.

_ViewStart.cshtml

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

Doing this you can share a common _Layout.cshtml file with all or only some of your Areas.


For more info about the _ViewStart.cshtml file be sure to check this answer:

https://stackoverflow.com/a/9300466/114029

Community
  • 1
  • 1
Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480