Relative Content

Tag Archive for blazor.net-8.0

Blazor NET 8 Web App-PersistentComponentState with Per-Page Rendering

I have a NET 8 Blazor web app that uses per-page rendering (nothing set globally) which renders my nav bar and main layout statically on the server. I navigate to a razor component page that sets the render mode at the component level (@rendermode InteractiveWebAssembly). If I try to use PersistentComponentState inside OnInitializedAsync(), I get the following error:

Blazor Landing Page from External Source with encrypted token

We are generating encrypted tokens for invitations sent to a user’s email. I need the user to be able to click on the link and land within my blazor app, have the token validated, and depending on the results either send the user through the Entra User Flow or send them to a 403 access denied.

Blazor NotFound and NotAuthorized not working in .net 8

I’m encountering an issue with .NET 8 and Blazor. The interactive render mode is set to Auto (Server and WebAssembly). The problem arises 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 require unauthorized requests to redirect to the login page and requests for non-existing pages to redirect to NotFound.

What is the minimal configuration for [Authorize] to work on Blazor template Home page?

I’m learning how authentication works in Blazor by playing around with a minimal implementation. I started with the Server template with auth “None” and the familiar Counter and Weather sample pages. I added a dummy AuthenticationStateProvider as shown below and changed the RouteView in Routes.razor to an AuthorizeRouteView without any additional configuration. I suspect this is where something else is required for the issue I’m having, maybe something to do with the special significance of the "/" route.

Should AuthorizeView care whether IIdentity.IsAuthenticated?

To better understand how authentication works in Blazor, I’m playing around with a minimal implementation of AuthenticationStateProvider. As expected, if I implement GetAuthenticationStateAsync() like this, an AuthorizeView displays the not-authorized content: