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.
-
1Can you post the relevant code? Hard to trouble shoot without seeing what you've tried.mituw16– mituw162015-08-04 19:32:57 +00:00Commented Aug 4, 2015 at 19:32
-
Is the view still trying to define the section for which you deleted the RenderSection? That's probably why.James R.– James R.2015-08-04 19:32:59 +00:00Commented Aug 4, 2015 at 19:32
Add a comment
|
1 Answer
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.