[EDIT by guardrex to add the error text to the comment]
Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Authorization requires a cascading parameter of type Task. Consider using CascadingAuthenticationState to supply this.
Description
I wrote the test project in accordance with the documentation, and I always encountered exceptions. I created a BlazorApp Server type project with.NET 8.0.
I have already add the CascadingAuthenticationState Routes.
Routes.razor
<CascadingAuthenticationState> <Router AppAssembly="@typeof(Program).Assembly"> <Found Context="routeData"> <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" /> <FocusOnNavigate RouteData="@routeData" Selector="h1" /> </Found> </Router> </CascadingAuthenticationState>
BlazorApp12.zip
Page URL
https://learn.microsoft.com/zh-cn/aspnet/core/blazor/security/server/?view=aspnetcore-8.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/security/server/index.md
Document ID
8da62490-e36f-8f38-8f06-d5d6bceaafde
Article author
guardrex
[EDIT by guardrex to add the error text to the comment]
Description
I wrote the test project in accordance with the documentation, and I always encountered exceptions. I created a BlazorApp Server type project with.NET 8.0.
I have already add the CascadingAuthenticationState Routes.
Routes.razor
<CascadingAuthenticationState> <Router AppAssembly="@typeof(Program).Assembly"> <Found Context="routeData"> <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" /> <FocusOnNavigate RouteData="@routeData" Selector="h1" /> </Found> </Router> </CascadingAuthenticationState>BlazorApp12.zip
Page URL
https://learn.microsoft.com/zh-cn/aspnet/core/blazor/security/server/?view=aspnetcore-8.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/security/server/index.md
Document ID
8da62490-e36f-8f38-8f06-d5d6bceaafde
Article author
guardrex