blazor-workshop
blazor-workshop copied to clipboard
Status Code Different
I am working through the Authentication tutorial and I have just added the [Authorize] attribute. I can no longer view my orders, but instead of getting a 302 as is indicated in the documentation, I am getting a 304 on myorders and a 401 on orders.
The issue is that the App.razor file in 00-get-started does not match the one in 06. It is missing the RedirectToLogin.
In order to get Authentication to work I added the RedirectToLogin.razor page and I updated the app.razor page from the Blazor WebAssembly template.
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (!context.User.Identity.IsAuthenticated)
{
<RedirectToLogin />
}
else
{
<p>You are not authorized to access this resource.</p>
}
</NotAuthorized>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
I see that you made the same changes later in the session. Interesting...
@ToiWright #253 should have fixed your issue. Can you check and close this issue (i.e. #251)? Thanks.