In asp.net mvc 4 project development you may face an error like "The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Class". and / or "The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "scripts".
It means that you have no definition for a section in your master Layout.cshtml, but you try to get that section from your View. To resolve this problem, check your view.cshtml has some thing like this
@section Class{
}
and / or
@section scripts{
}
If yes, you must define a section in your master Layout.cshtml like this
To fix this section defined but bot rendered error you just add this lines before the end of body tag in your Layout.cshtml
@RenderSection("scripts", required: false)
@RenderSection("Class", required: false)
Please share this post if it's useful to you. Thanks!.
2 comments:
Thanks
Hi Buddy
The RederSection statements sorted out my issue.
Thanks
Post a Comment
Share your thoughts here...