It sounds like you may need to setup your app to use a state container. Setup a test app with the following to see if it provides the general functionality you're looking for.
Create a new file called AppState.cs. You can place it anywhere for this example, so the Pages folder is fine. Add the following AppState class in there to use as the state container
public class AppState
{
public event EventHandler OnStateChanged;
public string AppText;
public virtual void NotifyStateChanged() => OnStateChanged?.Invoke(this, EventArgs.Empty);
public void RefreshAppState()
{
NotifyStateChanged();
}
}
In your Startup.cs file, add the following to your ConfigureServices method (you'll also need to add a using directive for your AppState file, so it will be recognized)
services.AddSingleton<AppState>();
Change your index.razor file to the following
@page "/"
@inject AppState appState
@implements IDisposable
<h1>My Blazor App</h1>
<button @onclick="@(() => HandleSubmit())">Submit</button>
Ticks: @appState.AppText
@code {
protected override void OnInitialized()
{
appState.OnStateChanged += HandleAppStateChange;
}
public void Dispose()
{
appState.OnStateChanged -= HandleAppStateChange;
}
void HandleSubmit()
{
appState.AppText = DateTime.Now.Ticks.ToString();
appState.RefreshAppState();
}
async void HandleAppStateChange(object sender, EventArgs args)
{
await InvokeAsync(() => StateHasChanged());
}
}
When you run this Blazor app now and you click on the Submit button, it should update all browsers with the same 'tick' text.