Skip to content

Commit 8bac288

Browse files
committed
Clarify when the InnerHandler must be assigned
1 parent 7643528 commit 8bac288

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

aspnetcore/blazor/security/webassembly/additional-scenarios.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ public class CustomAuthorizationMessageHandler : AuthorizationMessageHandler
300300
}
301301
```
302302

303+
> [!NOTE]
304+
> In this section, the preceding message handler is used when a configured <xref:System.Net.Http.HttpClient> is created from an injected <xref:System.Net.Http.IHttpClientFactory>. If you don't use an <xref:System.Net.Http.IHttpClientFactory>, you must create an <xref:System.Net.Http.HttpClientHandler> instance and assign it to the <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.AuthorizationMessageHandler>'s <xref:System.Net.Http.DelegatingHandler.InnerHandler%2A?displayProperty=nameWithType>:
305+
>
306+
> ```csharp
307+
> InnerHandler = new HttpClientHandler();
308+
> ```
309+
>
310+
> You don't need to make the preceding <xref:System.Net.Http.DelegatingHandler.InnerHandler> assignment if you use <xref:System.Net.Http.IHttpClientFactory>, as the `ExampleAPIMethod` call later in this section demonstrates.
311+
303312
In the preceding code, the scopes `example.read` and `example.write` are generic examples not meant to reflect valid scopes for any particular provider.
304313

305314
In the `Program` file, `CustomAuthorizationMessageHandler` is registered as a transient service and is configured as the <xref:System.Net.Http.DelegatingHandler> for outgoing <xref:System.Net.Http.HttpResponseMessage> instances made by a named <xref:System.Net.Http.HttpClient>.

0 commit comments

Comments
 (0)