【问题标题】:Blazor WebAssembly App with Individual User Accounts and Store user accounts in-app using gives no local user accounts具有个人用户帐户和应用程序内存储用户帐户的 Blazor WebAssembly 应用程序不提供本地用户帐户
【发布时间】:2021-03-09 15:14:02
【问题描述】:

使用Visual Studio 2019 16.8.2.NET 5.0 使用Individual User AccountsStore 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 AccountsStore user accounts in-app 创建另一个应用程序会提供ASP.NET Core Identity 身份用户和他们自己的数据库。

【问题讨论】:

    标签: c# visual-studio blazor blazor-webassembly .net-5


    【解决方案1】:

    您没有单击自托管,因此它想连接到现有服务器。

    【讨论】:

    【解决方案2】:

    您可以从 Index.razor 中删除它,这是 Index.razor 页面中的硬编码消息。

    【讨论】:

      猜你喜欢
      • 2021-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      • 2018-02-19
      • 1970-01-01
      相关资源
      最近更新 更多