Reputation: 39
Visual Studio creates a defualt _Layout.cshtml And I am trying to make different design; however, when the RenderSection() \code is deleted, the browser shows an error. It does not load. Can anyone show help me how to do it.
Upvotes: 0
Views: 230
Reputation: 840
If your view is trying to define a section such as:
@section Hello
{
<p>Hello</p>
}
And your _Layout never renders it:
@RenderSection("Hello")
Then you will get an exception such as:
"The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Hello"."
You must call RenderSection for all sections that your views define, or remove the sections from the view.
Upvotes: 2