c# - Blazor 个人帐户失败并显示 "ArgumentException: The path in ' 值'必须以 '/' 开头。 (参数 'value')”

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

我已经使用 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");
        });
    }
}

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

这让我发疯,我进行了搜索,尝试从错误处理中删除/添加 .json 中的所有 / 来自 .cs ,仍然出现错误。

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

最佳答案

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

关于c# - Blazor 个人帐户失败并显示 "ArgumentException: The path in ' 值'必须以 '/' 开头。 (参数 'value')”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60066709/

相关文章:

c# - 读取 ASN.1 DER 编码的 RSA 公钥

c# - VS.Net 2008 中 Windows 服务的控制台输出

c# - .net core IDistributedCache redis sentinel 支持master/slave

c# - 为ASP.NET运行Memcached

azure - 调用 CreateIfNotExists(Azure blob 客户端)时出现异常

c# - 将 Linq-to-SQL 中的计算属性映射到实际 SQL 语句

c# - 接口(interface)注解

asp.net - 关于 OWIN 管道

azure - 通过 Azure CLI 配置 Blob 存储的日志记录

azure - 来自 Google Cloud 的出站流量