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?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,772 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,662 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 71,101 Reputation points
    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.