title: How to store session data in server-side blazor
body: <p>In a server-side Blazor app I'd like to store some state that is retained between page navigation. How can I do it?</p>
  
  <p>Regular ASP.NET Core session state does not seem to be available as most likely the following note in <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/app-state?view=aspnetcore-2.2" rel="noreferrer">Session and app sate in ASP.NET Core</a> applies:</p>
  
  <blockquote>
    <p>Session isn't supported in <a href="https://docs.microsoft.com/aspnet/signalr/index" rel="noreferrer">SignalR</a>
    apps because a <a href="https://docs.microsoft.com/en-us/aspnet/core/signalr/hubs?view=aspnetcore-2.2" rel="noreferrer">SignalR Hub</a> may
    execute independent of an HTTP context. For example, this can occur
    when a long polling request is held open by a hub beyond the lifetime
    of the request's HTTP context.</p>
  </blockquote>
  
  <p>The GitHub issue <a href="https://github.com/aspnet/AspNetCore/issues/5330" rel="noreferrer">Add support to SignalR for Session</a> mentions that you can use <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.signalr.hubconnectioncontext.items?view=aspnetcore-2.1#Microsoft_AspNetCore_SignalR_HubConnectionContext_Items" rel="noreferrer">Context.Items</a>. But I have no idea how to use it, i.e. I don't know hot to access the <code>HubConnectionContext</code> instance.</p>
  
  <p>What are my options for session state?</p>