ASP.NET MVC 4 - Solution: The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Class". or "Scripts" | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

ASP.NET MVC 4 - Solution: The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Class". or "Scripts"

Friday

ASP.Net MVC 4 Razor: Section Defined But Not Rendered Error:
                            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:

Unknown said...

Thanks

Anonymous said...

Hi Buddy
The RederSection statements sorted out my issue.
Thanks

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets