Use the ASP.NET MVC layout for all Areas

Areas in an ASP.NET MVC web application doesn’t use the layout of your web application by default. The reason (as far as I understand) is that your _ViewStart.cshtml which is usually located in ~/Views/ is only visible by views in that folder and its sub-folders.

So the solution, turns out, was more or less just to move that file up a level.

  1. Move ~/Views/_ViewStart.cshtml to ~/_ViewStart.cshtml.
  2. Cut or copy the following elements from ~/Views/Web.config and merge them into ~/Web.config. I say merge, because configSections for example probably already exists, so put the sectionGroup inside it. Don’t know if the Web.config handles multiple configSections…
      <configSections>
        <sectionGroup name="system.web.webPages.razor" ...>
          ...
        </sectionGroup>
      </configSections>

      <system.web.webPages.razor>
        ...
      </system.web.webPages.razor>

All areas should now use the the same layout as the rest of your application.