asp.net-coreasp.net-identityrazor-pagesasp.net5

Full identity scaffolding fails because of Razor script tag


I scaffolded all the Razor views, because I want to edit them.

However some of them have this at the bottom:

@section Scripts {
<partial name="_ValidationScriptsPartial" />
}

This is the error that I get:

InvalidOperationException: The following sections have been defined but have not been rendered by the page at '/Areas/Identity/Pages/Account/Manage/_Layout.cshtml': 'Scripts'. To ignore an unrendered section call IgnoreSection("sectionName").

Note that I do want those scripts to be rendered. Why does it crash? How to best resolve it?


Solution

  • Refer to this thread.

    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.

    In your /Areas/Identity/Pages/Account/Manage/_Layout.cshtml,it should include the code:

    @section Scripts 
    {
        @RenderSection("Scripts", required: false)
    }