Skip to content
This repository was archived by the owner on Dec 26, 2025. It is now read-only.
This repository was archived by the owner on Dec 26, 2025. It is now read-only.

Is it possible to use LocalStorage in a DelegatingHandler? #151

@redowl5

Description

@redowl5

We have a server side Blazor project and looking to add JWT tokens (which are being saved using LocalStorage on login) to all httpclient requests by using a delegatingHandler.

The delegating handler includes the line

var savedToken = await _myLocalStorageService.GetItemAsync("jwt");

where _myLocalStorageService has the constructor

public MyLocalStorageService(ILocalStorageService storage)

Regardless of when the delegating handler gets called, we get the "JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered. " when calling GetItemAsStringAsync

Any ideas?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionQuestion about this projectResolved: DuplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions