Update additional-scenarios.md (#23650)
parent
5265cf454c
commit
f6730f65c4
|
@ -34,6 +34,7 @@ using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
|
|||
|
||||
...
|
||||
|
||||
// AddHttpClient is an extension in Microsoft.Http.Extensions
|
||||
builder.Services.AddHttpClient("WebAPI",
|
||||
client => client.BaseAddress = new Uri("https://www.example.com/base"))
|
||||
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
|
||||
|
@ -98,6 +99,7 @@ In `Program.cs`, `CustomAuthorizationMessageHandler` is registered as a scoped s
|
|||
```csharp
|
||||
builder.Services.AddScoped<CustomAuthorizationMessageHandler>();
|
||||
|
||||
// AddHttpClient is an extension in Microsoft.Http.Extensions
|
||||
builder.Services.AddHttpClient("WebAPI",
|
||||
client => client.BaseAddress = new Uri("https://www.example.com/base"))
|
||||
.AddHttpMessageHandler<CustomAuthorizationMessageHandler>();
|
||||
|
@ -210,6 +212,7 @@ using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
|
|||
|
||||
...
|
||||
|
||||
// AddHttpClient is an extension in Microsoft.Http.Extensions
|
||||
builder.Services.AddHttpClient<WeatherForecastClient>(
|
||||
client => client.BaseAddress = new Uri("https://www.example.com/base"))
|
||||
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
|
||||
|
@ -237,6 +240,7 @@ The handler can be further configured with <xref:Microsoft.AspNetCore.Components
|
|||
In `Program.cs`:
|
||||
|
||||
```csharp
|
||||
// AddHttpClient is an extension in Microsoft.Http.Extensions
|
||||
builder.Services.AddHttpClient<WeatherForecastClient>(
|
||||
client => client.BaseAddress = new Uri("https://www.example.com/base"))
|
||||
.AddHttpMessageHandler(sp => sp.GetRequiredService<AuthorizationMessageHandler>()
|
||||
|
@ -257,6 +261,7 @@ If the Blazor WebAssembly app ordinarily uses a secure default <xref:System.Net.
|
|||
In `Program.cs`:
|
||||
|
||||
```csharp
|
||||
// AddHttpClient is an extension in Microsoft.Http.Extensions
|
||||
builder.Services.AddHttpClient("WebAPI.NoAuthenticationClient",
|
||||
client => client.BaseAddress = new Uri("https://www.example.com/base"));
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue