【发布时间】:2021-03-09 15:14:02
【问题描述】:
使用Visual Studio 2019 16.8.2 和.NET 5.0 使用Individual User Accounts 和Store user accounts in-app 创建一个新的Blazor WebAssembly App 不会提供本地用户帐户。
启动它说的应用程序:
在身份验证正常运行之前,您必须配置您的 Program.cs 中的提供程序详细信息
程序.cs:
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddOidcAuthentication(options =>
{
// Configure your authentication provider options here.
// For more information, see https://aka.ms/blazor-standalone-auth
builder.Configuration.Bind("Local", options.ProviderOptions);
});
await builder.Build().RunAsync();
}
}
点击登录重定向到:
https://localhost:44444/authentication/login-failed
带有以下信息:
尝试让您登录时出错:'无效响应 内容类型:text/html,来自 URL: https:login.microsoftonline.com/.well-known/openid-configuration'
wwwroot -> appsettings.json 看起来像这样:
{
"Local": {
"Authority": "https://login.microsoftonline.com/",
"ClientId": "33333333-3333-3333-33333333333333333"
}
}
https://aka.ms/blazor-standalone-auth 导致https://docs.microsoft.com/en-gb/aspnet/core/blazor/security/webassembly/?view=aspnetcore-3.1
独立的 Blazor WebAssembly 应用似乎需要 Azure Active Directory (AAD)、Azure Active Directory B2C (AAD B2C) 或另一个 Identity Provider (IP)。
使用Individual User Accounts 和Store user accounts in-app 创建另一个应用程序会提供ASP.NET Core Identity 身份用户和他们自己的数据库。
【问题讨论】:
标签: c# visual-studio blazor blazor-webassembly .net-5