AddIdentity() fails “InvalidOperationException: Scheme already exists: Identity.Application”

前端 未结 7 682
闹比i
闹比i 2021-01-07 22:05

I\'m trying to add facebook login to my .NET Core 2.1 site

I\'m following this , guide and more specific, this (for facebook login)

After have adding the lines

7条回答
  •  时光取名叫无心
    2021-01-07 22:29

    For me (ASP.NET Core v2), I had:

    services.AddIdentity()
                        .AddEntityFrameworkStores()
                        .AddUserStore()
                        .AddRoleStore()
                        .AddRoleManager()
                        .AddDefaultTokenProviders();
    

    in Startup.cs. And when I scaffolded Identity, it added IdentityHostingStartup.cs, and I had copy/pasted another similar but default block in based on some email sending code:

    builder.ConfigureServices((context, services) =>
                    {
                        services.AddDefaultIdentity(config =>
                        {
                            config.SignIn.RequireConfirmedEmail = false;//TODO:
                        })
                        .AddEntityFrameworkStores();
                    });
    

    So I moved ALL Identity config into IdentityHostingStartup.cs (ie only 1 configure!!!) it worked as expected...

提交回复
热议问题