Managing Blazor Server Page State

Aima Maqsood 25 Reputation points
2025-03-04T04:51:04.4266667+00:00

Hi, I want to know about is there any method or technique available through which we can store our significant variables/maintain the page state in sessions under Blazor Server Pages? We are developing a high level blazor server application which needs to meet the CISCO CSDL Items (security items), where we can't store the data/values in Local storage/session storage even in cookies (except for encrypted JWT Token).

Context:

We are working on Replication Management (SQL Server Replication) where I need to store the page state and buttons state, like if replication is done, it should enable the un-install replication/re-initialized replication button and saved the state, even after user logs out from the application. Or if user un-install the replication, that button will be disable along with re-initialized replication button, and enable the install replication button, and saved the state for the user.

Blazor Training
Blazor Training
Blazor: A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.Training: Instruction to develop new skills.
19 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Zhi Lv - MSFT 33,151 Reputation points Microsoft External Staff
    2025-03-05T01:37:37.34+00:00

    Hi @Aima Maqsood

    I want to know about is there any method or technique available through which we can store our significant variables/maintain the page state in sessions under Blazor Server Pages? We are developing a high level blazor server application which needs to meet the CISCO CSDL Items (security items), where we can't store the data/values in Local storage/session storage even in cookies (except for encrypted JWT Token).

    Since you can't store state in Local Storage, Session Storage, or Cookies (except for an encrypted JWT token), your best approach is to use server-side storage. Options include:

    • Blob storage
    • Key-value storage
    • Relational database
    • Table storage

    You can create a table to store state per user and store the state of replication actions per user.

    After data is saved, the user's state is retained and available in any new circuit. For more information on Azure data storage options, see the following:

    More detail information, see ASP.NET Core Blazor state management#Server-side storage.

    Besides, you could also consider using Azure Redis Cache, refer to:

    Quickstart: Use Azure Redis with an ASP.NET web app

    Distributed caching in ASP.NET Core


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Dillion

    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.