Blazor WebAssembly Identity scaffolding issues
See original GitHub issueBlazor webassembly version: dotnet new -i Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0-preview5.20216.8
Creating new project blazer web assembly with Authentication and asp.netcore hosted
after Scaffold applied for Identity, I am getting the error: 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”).
it will “fix” if I change: Server/Page/Shared/_Layout.cshtml
remove:
@section Scripts {
@RenderSection("Scripts", required: false)
}
and replace for:
@{
@if (IsSectionDefined("Scripts"))
{
IgnoreSection("Scripts");
}
}
however the JS wont be populated from pages using this template via:
@section Scripts {
<partial name="_ValidationScriptsPartial" />
}
I am missing any configuration to get that sorted?
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (10 by maintainers)
Top Results From Across the Web
Error scaffolding identity in blazor webassembly app
I am building a webassembly project in Razor using Visual Studio 2019 (version 16.9.4) and whenever I try to scaffold the identity I...
Read more >Blazor WebAssembly Add Identity Scaffolding · Issue #22712
After creating a new Blazor WebAssembly app then adding Identity Scaffolding. Next, run the app and goto the Fetch page and receive exception:...
Read more >Scaffolding failing for identity in blazor - Microsoft Q&A
When I try to add identity thru the cli cause the tooling is broken form the gui I get this error. I am...
Read more >Need Input Regarding Authentication/Identity for New ...
I went through the process of scaffolding all the Identity files, that process introduced several issues which were really annoying to fix ...
Read more >Identity with a .NET 6 Web API & Blazor WebAssembly
NET 6 Web API & Blazor WebAssembly 03:39 Create the Project 06:11 ... a User 21:20 Scaffolding Identity Files 27:33 Add a Relationship...
Read more >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
~@deepchoudhery It looks like the Identity scaffolder generates a layout into the server project that doesn’t render the Scripts section used by the Identity pages to add required scripts to the page.~
Correction: The problematic layout comes from the Blazor WebAssembly template, not from the scaffolder.
The generated Pages/Shared/_Layout.cshtml looks like this:
But it needs to render the Scripts section like this:
@HaoK Whoops! You’re right. I need to work on my diff’ing skills 😝
There is a default minimalistic layout in the Blazor WebAssembly server project that doesn’t render the Scripts section. Looks like we need to address the layout issue in the Blazor WebAssembly template. Closing this issue as a dup of https://github.com/dotnet/aspnetcore/issues/22712. I’ll open a separate issue for the view imports issue.