How to save page load performance in blazor when navigating from one page to other in new tab?

Piyush Meshram 20 Reputation points
2024-01-18T10:46:06.7133333+00:00

If a Blazor app with Individual user accounts is created then if we open a new line user Authorization is performed again which impacts the performance and page load.

for example: if we show a document anchor tag, then if that anchor opens in a new tab the full blazor lifecycle is performed including the Authorization of the user. Can we avoid this by maintaining user sessions a bit differently?

Developer technologies ASP.NET ASP.NET Core
Developer technologies .NET Blazor
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-01-18T17:10:54.91+00:00

    loading an blazor app into a new tab requires creating a new blazor instance, and rerunning the authentication logic.

    if you are using cookie authentication (blazor server), you can reduce the logic by requiring the blazor hosting page to require authorization. if the original cookie has not expired, it will not need to redirect to the long service. if you are storing jwt tokens, then you want a persistent store keyed by the username key.

    if you are using blazor WASM, you can store the authentication tokens in localstorage, and check first at load (need custom authentication state provider).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.