Solution
The exception occurs if you have defined a section in your master Layout.cshtml, but you have not included anything for that section in your View.
If your _Layout.cshtml has something like this:
@RenderSection("scripts")
Then all your Views that use that Layout must include a @section
with the same name (even if the contents of the section are empty):
@{
ViewBag.Title = "Title";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section scripts{
// Add something here
}
Leave a Reply