Skip to content

Doc proposal for persisting state in server-side Blazor #13259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SteveSandersonMS opened this issue Jul 12, 2019 · 4 comments · Fixed by #13364
Closed

Doc proposal for persisting state in server-side Blazor #13259

SteveSandersonMS opened this issue Jul 12, 2019 · 4 comments · Fixed by #13364

Comments

@SteveSandersonMS
Copy link
Member

As a result of dotnet/aspnetcore#11793, I've written up some detailed guidance about why you need to persist state in server-side Blazor, and how to do it. This is in a gist at https://gist.github.com/SteveSandersonMS/ba16f6bb6934842d78c89ab5314f4b56.

Is it possible to convert this into a doc page? I hope the content is in decent shape already, though I'm sure you'll want to put it through the usual copyediting and stylistic changes needed to fit in with the rest of the docs. cc @guardrex

Note that the gist refers to a package called ProtectedBrowserStorage that hasn't yet been published, but is in a PR at aspnet/AspLabs#198. Hopefully we'll publish the package soon (though it will remain experimental for now).

@guardrex
Copy link
Collaborator

guardrex commented Jul 15, 2019

@danroth27 @SteveSandersonMS Putting the final touches on this now.

Done! ... but I need the answers to 👇 before wrapping it up and submitting it.

  1. Microsoft.AspNetCore.ProtectedBrowserStorage isn't on NuGet. Which of the following is best ...

    • Say to use the labs repo to create it.

      I hit a snag locally tho: I don't get JsonSerializerOptions or JsonSerializer with System.Text.Json. If I bring in System.Text.Json.Serialization instead, I get JsonSerializerOptions, but the JsonSerializer doesn't have Serialize and Deserialize. I see the methods on master in engineering, but I don't have them here. Seems like I need to global.json-myself a dev package feed for the time being. If that's correct, wouldn't it be best to release this topic with Pre7?

    • Go ahead and link NuGet ... the Microsoft.AspNetCore.ProtectedBrowserStorage package will be there shortly. (Or, it will be there for Pre7 release.)

  2. WRT ...

    The server can't retain disconnected circuits forever. The server must release disconnected circuits after a timeout or when the server is under memory pressure. The timeout and retention limits are configurable. The timeout and retention limits are configurable.

    How? [We could also punt on this with a new issue to address it later. 🏃😅 If you want to skip this for now, I'll remove the "timeout and limits" sentence.]

  3. Finally ...

    Microsoft.AspNetCore.ProtectedBrowserStorage ... can it be used in Blazor client-side apps, not just the client-side of a Blazor server-side app? It seems so except for the DP angle, which makes it seems like 'NO' ... it can't. Double-checking: Is the whole topic and the package strictly for server-side as you originally stated? If so, I'll make that clear to the reader.

@guardrex
Copy link
Collaborator

guardrex commented Jul 17, 2019

@SteveSandersonMS The topic is almost ready. Can you answer ☝️ those questions for me to put the final touches on it?

@SteveSandersonMS
Copy link
Member Author

Thanks @guardrex! I'm just working on getting ProtectedBrowserStorage published to NuGet.org at the moment. I was hoping to get that done before confirming we're ready to merge this into the docs.

How? [We could also punt on this with a new issue to address it later. 🏃😅 If you want to skip this for now, I'll remove the "timeout and limits" sentence.]

If that's not in docs already, then we're missing some docs. If you don't mind filing a docs issue, we can assign it to the appropriate dev to get the definitive info.

Double-checking: Is the whole topic and the package strictly for server-side as you originally stated? If so, I'll make that clear to the reader.

The ProtectedBrowserStorage library is only for server-side Blazor. It's a netcoreapp3.0 package, so you can't even add a reference to it if you're on client-side Blazor.

As for the broader concepts of using localStorage, you can definitely do that from client-side Blazor using some other package, but it's not what this doc attempts to address. This doc is only about the specific concerns for server-side Blazor as its statefulness is very different to client-side Blazor where it's impossible to "drop the connection".

@guardrex
Copy link
Collaborator

guardrex commented Jul 17, 2019

Thanks ...

  1. I'll assume the package is on NuGet in terms of what the doc states.

  2. Opened Document "circuits" for Blazor server-side #13360 to document the concept of circuits (and I presume limits/timeouts). Idk if "circuits" maps to something existing in ASP.NET Core that we already document, including limits/timeouts. SignalR limits/timeouts seem either too short to apply here or perhaps are missing them if that's where the limits/timeouts come from for circuits.

  3. "not what this doc attempts to address" 👉 Gotcha. I'll check/update the wording to make sure it's clear that this is for server-side Blazor and that client-side requires custom code or a 3rd party package.

I'll ping you for review on this one because I did work extensively with phrasing. We want to make sure that I didn't break your meaning in the process. I'll have it submitted in a few hours after I get back from the 💪 gym.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants