Skip to content

The following sections have been defined but have not been rendered for the layout page “~/Views/Shared/_Layout.cshtml”: “Scripts”

January 6, 2016

If you receive the following error in ASP NET MVC ,

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 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 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
}
Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: