I am implementing AuthorizeRouteView in App.razor file of Blazor Server App but I always get an error when the application runs
InvalidOperationException: JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered. When prerendering is enabled, JavaScript interop calls can only be performed during the OnAfterRenderAsync lifecycle method.
Below is the App.razor content
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<Login />
</NotAuthorized>
</AuthorizeRouteView>
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<CascadingAuthenticationState>
<LayoutView Layout="@typeof(MainLayout)">
</LayoutView>
</CascadingAuthenticationState>
</NotFound>
Even if I comment out the Login component the error still shows.
What am I missing
question from:
https://stackoverflow.com/questions/65925879/javascript-interop-calls-error-when-using-authorizerouteview-in-blazor-server-ap 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…