Saturday 26 May 2018

c# - How to store session data in server-side blazor

In a server-side Blazor app I'd like to store some state that is retained between page navigation. How can I do it?



Regular ASP.NET Core session state does not seem to be available as most likely the following note in Session and app sate in ASP.NET Core applies:





Session isn't supported in SignalR
apps because a SignalR Hub 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.




The GitHub issue Add support to SignalR for Session mentions that you can use Context.Items. But I have no idea how to use it, i.e. I don't know hot to access the HubConnectionContext instance.




What are my options for session state?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...