Skip to content

Persisting Data Across SSR and Blazor Server #50741

Closed
@darena-pjindal

Description

@darena-pjindal

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This is not a bug. I am hoping there is a best-practice answer for this. We have a scenario where a page loads as SSR, but then the interactive Blazor server component takes over. We need to call an API to a secured endpoint from the interactive component. We already have the access token during the SSR call. We create a scoped service and use that to save the access token when the SSR page loads. Then, we can get the access token back from that service in the interactive component to make the calls to the API. Is it ok to assume that a scoped service will stay between a SSR call and the Signal R session. If not, how do you share data between SSR and Signal R session. We saw that we could use the persist pre-render state but not sure if that is a better way. Thanks in advance for help.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

dotnet8

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions