The following sections were defined but not displayed for the layout page "~ / Views / Shared / _Layout.cshtml": "featured"

I know there have been many questions about this error, and there have always been answers about

@RenderSection("scripts", required: false)

But my _Layout.cshtml file does not have this section. My file:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")"></script>
</head>
<body>
    <ul id="menu">
        <li>@Html.ActionLink("Główna", "Index", "Home")</li>
        <li>@Html.ActionLink("Uzytkownicy", "Index", "Database")</li>
        <li>@Html.ActionLink("O systemie", "About", "Home")</li>
    </ul>
    <section id="main">
        @RenderBody()
        <p>Copyright 2015. All Rights Reserved.</p>
    </section>
</body>
</html>

I tried:

  • enter "scripts" required: false "on @RenderBody (),
  • remove scripts from head section
  • put @RenderSection ("scripts", required: false) in the chapter section above the scripts.

None of this helped me.

+4
source share
1 answer

, , . , , , , RenderSection() .

, - featured, "featured".

<body>
    <section id="main">

        @RenderBody()

        @RenderSection("featured", required: false)

    </section>
</body>

featured section .

, @RenderSection("scripts",required:false) , JavaScript javascript .

+5

Source: https://habr.com/ru/post/1625048/


All Articles