blazor hosted wasm local identity - error on scaffold login page

231 views Asked by At

I have created a standard hosted wasm with local authentication added.

I have also added the scaffold items for identity (add > scaffold > Identity - specify the _layout specify the dbcontext and select account/login and account/logout items)

This created some scaffold pages in areas/identity/pages/account - login.cshtml and logout cshtml

on rebuilding the solution and running I now get an error when navigating to the login page:

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

on further testing this relates to the following script block on the login.cshtml file

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

if i delete this then the error goes away - but it seems it is intended to include various scripts in the _ValidationScriptsPartial.cshtml file so I am concerned I am losing something.

Any thoughts on how to get the @section Scripts{} block working appropriately.

note - i have tried this on 3 different solutions 2x ones i have pissed about with and 1x brand new boilerplate vs2019 solution.

help very much appreciated.

1

There are 1 answers

0
Mgwd On BEST ANSWER

Try adding the following to _Layout.cshtml just before the closing </body> tag in the server project:

@RenderSection("Scripts", required: false)