In-Memory State Container Service in Blazor
This blog is going to explain how to carry data from page to page or component. In the Blazor application, you can achieve this by injecting application state, dependency injection, and custom class. This state will persist in the browser's memory. So when the user navigates through the browser, they will get the same data. But this data will be cleared when the user refreshes the page. Let's look at the in-memory state process step by step. This example is going to illustrate how to manage in-memory state values from one child to another. Step1: First, I created the StateContainer class. StateContainer.cs public class StateContainer { public List < string > MovieList { get ; set ;} = new List < string >(); public void SetValue ( string value ) { MovieList . Add ( value ); NotifyStateChanged (); } public event Action ? OnChange ; private void NotifyStateChanged ()