Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor NotFound and NotAuthorized not working in .net 8

$
0
0

I'm facing an issue with .NET 8 and Blazor. The interactive render mode is set to Auto (Server and WebAssembly). The problem is when I add NotAuthorized and NotFound it fails to navigate to either my Login page or my NotFound page. Adding UseStatusCodePagesWithRedirects allows me to navigate to one of the pages, but I want unauthorized requests to redirect to the login page and requests for non-existing pages to redirect to NotFound.

If the page doesn't exist, it will display the default browser error "page not found." If the page does exist and I'm not logged in, it will navigate to "account/login" instead of "/login," which is the path of my Login component.

Do you have any ideas on how to achieve this? I've searched the internet but couldn't find a full solution to my problem.

@using HTPB.Client.Pages@using Microsoft.AspNetCore.Components.Authorization<CascadingAuthenticationState><Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new[] { typeof(Client._Imports).Assembly }"><Found Context="routeData"><AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)"><NotAuthorized><Login></Login></NotAuthorized></AuthorizeRouteView></Found><NotFound><NotFound></NotFound></NotFound></Router></CascadingAuthenticationState>

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>