The following
sections have been defined but have not been rendered for the layout page
"~/Views/Shared/_Layout.cshtml": "Scripts".
Solution 1 : If the _Layout.cshtml has the following piece
of code:
@RenderSection("scripts")
Add the following in your cshtml file:
@{
ViewBag.Title = "My Title";
Layout = "~/Views/Shared/_Layout.cshtml";
}
//Add the blank section
@section scripts{
// Add something here
}
Solution 2 : Alternative approach:
@if (IsSectionDefined("scripts"))
{
RenderSection("scripts")
}
Solution 3: You can try another alternative approach as
below:
@RenderSection("scripts", required: false)
Where exactly do I have to put these statements? Is it in my layout view or in my controller view?
ReplyDeleteyes, very nice..!
ReplyDelete