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?
Asked
Active
Viewed 268 times
1

AJ.
- 16,368
- 20
- 95
- 150
1 Answers
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:

Community
- 1
- 1

Leniel Maccaferri
- 100,159
- 46
- 371
- 480
-
Neither area has a `_ViewStart`. Are you saying I should add it? – AJ. Feb 21 '13 at 18:28