I have _ViewStart defining the main layout for my project (header, footer).
In this project, I have several areas. Each area has the same header and footer, as well as its own side menu. To do this, I created _ViewStart in the root directory of this area. Here is the (simplified) code:
/Views/_ViewStart.cshtml
@{ Layout = "~/Views/Shared/_Layout.cshtml"; }
/Views/Shared/_Layout.cshtml
<html> <div> //header </div> <div> @RenderBody </div> </html>
Foo scope -> /Areas/Foo/Views/_ViewStart.cshtml
@{ Layout = "~/Views/Shared/_Layout.cshtml"; } <div class="row"> <div class="sidemenu">
The page / Areas / Foo / Views / Bar / Index.cshtml will not be displayed, and I get this error:
CS0103: the name "RenderBody" does not exist in the current context
How to achieve this kind of nesting of the main page?
source share