【问题标题】:No authentication handler is configured to handle the scheme: Identity.Application没有配置身份验证处理程序来处理该方案:Identity.Application
【发布时间】:2016-10-06 10:46:40
【问题描述】:

我在成功注册用户并确认身份验证后收到上述错误。当我尝试调用时发生错误

await _signInManager.SignInAsync(applicationUser, isPersistent);

我首先将服务分配给 IServiceCollection:

services.AddIdentity<ApplicationUser, IdentityRole<int>>(
            config => { config.User.RequireUniqueEmail = true;
                config.Cookies.ApplicationCookie.LoginPath = "/Account/Login";
                config.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents()
                {
                    OnRedirectToLogin = async ctx =>
                    {
                        if (ctx.Request.Path.StartsWithSegments("/api") && ctx.Response.StatusCode == 200)
                        {
                            ctx.Response.StatusCode = 401;
                        }
                        else
                        {
                            ctx.Response.Redirect(ctx.RedirectUri);
                        }
                        await Task.Yield();
                    }
                };
            }).AddEntityFrameworkStores<VisualJobsDbContext, int>()
          .AddDefaultTokenProviders();

在我的 Config 启动方法中,我在调用 app.UseMvc 之前调用 app.UseIdentity();

如果我将呼叫更改为:

var myVal = await _signInManager.PasswordSignInAsync(applicationUser, password, true, false);

他们的 myVal 是 'Failed' 我没有收到任何错误抛出

【问题讨论】:

    标签: asp.net-core asp.net-identity


    【解决方案1】:

    尝试将app.UseIdentity(); 添加到Startup.cs Configure 方法中,如本答案No authentication handler is configured to authenticate for the scheme: Microsoft.AspNet.Identity.External 中所述

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-09
    相关资源
    最近更新 更多