Skip to content

Commit 392a090

Browse files
authored
Improve GetAuthenticationStateAsync exception message (#48812)
1 parent 4f1e7fb commit 392a090

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Components/Server/src/Circuits/ServerAuthenticationStateProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class ServerAuthenticationStateProvider : AuthenticationStateProvider, IH
1515
/// <inheritdoc />
1616
public override Task<AuthenticationState> GetAuthenticationStateAsync()
1717
=> _authenticationStateTask
18-
?? throw new InvalidOperationException($"{nameof(GetAuthenticationStateAsync)} was called before {nameof(SetAuthenticationState)}.");
18+
?? throw new InvalidOperationException($"Do not call {nameof(GetAuthenticationStateAsync)} outside of the DI scope for a Razor component. Typically, this means you can call it only within a Razor component or inside another DI service that is resolved for a Razor component.");
1919

2020
/// <inheritdoc />
2121
public void SetAuthenticationState(Task<AuthenticationState> authenticationStateTask)

0 commit comments

Comments
 (0)