Skip to content

Accessing AuthenticationStateProvider from DbContext or Startup.cs #30982

@mrlife

Description

@mrlife

Is it possible to access Blazor's AuthenticationStateProvider from a DbContext or in Startup.Configure()?

I receive this error:

GetAuthenticationStateAsync was called before SetAuthenticationState.

@Blackleones, did you ever get this line to work in your DbContext? ref #17442 (comment)

var userId = await _currentUserService.GetUserId();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions