Example throws unhandled error
I'm using the latest Visual Studio 2019 and .Net Core as of 10/30/2020
Steps to reproduce:
Create new Blazor Web app using template in Visual Studio 2019
Install Microsoft.Extensions.Http Install Microsoft.AspNetCore.Components.WebAssembly.Authentication
Add using Microsoft.AspNetCore.Components.WebAssembly.Authentication; to Program.cs
Replace: builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
With:
builder.Services.AddHttpClient("ServerAPI",
client => client.BaseAddress = new Uri("https://www.example.com/base"))
.AddHttpMessageHandler
builder.Services.AddScoped(sp => sp.GetRequiredService
Add new component 'Test' to Pages folder
Added to top of Test: @page "/Test" @using Microsoft.AspNetCore.Components.WebAssembly.Authentication @inject HttpClient Client
Added the new Test component to the NavMenu
Run in IISExpress in Chrome
Choose Test from the menu
Unhandled exception thrown: Unhandled exception rendering component: No service for type 'Microsoft.AspNetCore.Components.WebAssembly.Authentication.BaseAddressAuthorizationMessageHandler' has been registered.
What am I missing?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 53f3209c-2414-9b35-6245-383c9b7c6338
- Version Independent ID: cc8dfcd6-8d93-5aa3-c381-2b613e88cdbe
- Content: ASP.NET Core Blazor WebAssembly additional security scenarios
- Content Source: aspnetcore/blazor/security/webassembly/additional-scenarios.md
- Product: aspnet-core
- Technology: aspnetcore-blazor
- GitHub Login: @guardrex
- Microsoft Alias: riande
Hello @ChuckBevitt ... Why aren't you following the guidance in the dedicated topic?
https://docs.microsoft.com/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory
@ChuckBevitt I'm going to close the issue because we don't have anything actionable for documentation at this time. I recommend that you follow the guidance in the dedicated Hosting with AAD topic, then adopt any desired scenarios from the Additional scenarios topic after that.