【问题标题】:Blazor individual account fails with "ArgumentException: The path in 'value' must start with '/'. (Parameter 'value')"Blazor 个人帐户失败并显示“ArgumentException:'value' 中的路径必须以'/'开头。(参数'value')”
【发布时间】:2020-02-04 22:53:46
【问题描述】:

我已经使用 VS2019 社区向导创建了 Blazor 应用程序。我选择了个人帐户并进行了如下配置:

    "AzureAdB2C": {
    "Instance": "https://my-domain-from-azure.b2clogin.com/tfp/",
    "ClientId": "copy-pasted-guid-from-azure-here",
    "CallbackPath": "https://localhost:44308/signin-oidc/",
    "Domain": "my-domain-from-azure.onmicrosoft.com",
    "SignUpSignInPolicyId": "B2C_1_xxxx_signup_signin",
    "ResetPasswordPolicyId": "B2C_1_xxxx_password_reset",
    "EditProfilePolicyId": "B2C_1_xxxx_edit"
}

下一次启动看起来与启动时一模一样:

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddAuthentication(AzureADB2CDefaults.AuthenticationScheme)
            .AddAzureADB2C(options => Configuration.Bind("AzureAdB2C", options));

        services.AddRazorPages();
        services.AddServerSideBlazor();
        services.AddSingleton<WeatherForecastService>();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("Error");
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseStaticFiles();

        app.UseRouting();

        app.UseAuthentication();
        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
            endpoints.MapBlazorHub();
            endpoints.MapFallbackToPage("/_Host");
        });
    }
}

当我尝试运行应用程序时,我收到以下错误消息:

这让我发疯,我搜索了 SO,试图从错误处理中从 .json.cs 中删除/添加所有 /,但仍然发生错误。

知道我错过了什么,做错了吗?

【问题讨论】:

  • 尝试将此行 app.UseExceptionHandler("Error"); 替换为此 app.UseExceptionHandler("/Error"); 看看是否有帮助。
  • 尝试将您的 CallbackPath 更改为 /signin-oidc - 即相对 url?
  • @MisterMagoo 如果您可以将其作为答案,我非常乐意将其标记为答案:)

标签: c# asp.net azure .net-core blazor


【解决方案1】:

尝试将您的 CallbackPath 更改为 /signin-oidc - 即相对 url

【讨论】:

    猜你喜欢
    • 2017-06-09
    • 1970-01-01
    • 2020-02-15
    • 2018-08-05
    • 1970-01-01
    • 2022-12-10
    • 1970-01-01
    • 1970-01-01
    • 2021-04-21
    相关资源
    最近更新 更多