Section only applies to Blazor Server (#24993)

pull/24994/head
Luke Latham 2022-02-14 11:33:34 -06:00 committed by GitHub
parent 6f15198ab7
commit ff595089b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 11 deletions

View File

@ -118,6 +118,8 @@ For more information on dependency injection (DI) and services, see <xref:blazor
## Implement a custom AuthenticationStateProvider ## Implement a custom AuthenticationStateProvider
*This section only applies to Blazor Server.*
If the app requires a custom provider, implement <xref:Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider> and override `GetAuthenticationStateAsync`: If the app requires a custom provider, implement <xref:Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider> and override `GetAuthenticationStateAsync`:
```csharp ```csharp
@ -141,17 +143,7 @@ public class CustomAuthStateProvider : AuthenticationStateProvider
} }
``` ```
In a Blazor WebAssembly app, the `CustomAuthStateProvider` service is registered in `Main` of `Program.cs`: The `CustomAuthStateProvider` service is registered in `Program.cs`:
```csharp
using Microsoft.AspNetCore.Components.Authorization;
...
builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthStateProvider>();
```
In a Blazor Server app, the `CustomAuthStateProvider` service is registered in `Program.cs`:
```csharp ```csharp
using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Authorization;