Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

No authentication handler is configured to handle the scheme: Identity.Application

$
0
0

I receive the above error after I have successfully registered a user and confirmed authentication. The error occurs when I try to call

await _signInManager.SignInAsync(applicationUser, isPersistent);

I first assign the service to the IServiceCollection with this:

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();

and in my Config method of startup I call 

app.UseIdentity();
 before the call to app.UseMvc

if I change my call to be:

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

them myVal gives back 'Failed' when it should have succeeded. An error doesn't get thrown either, so I suspect it's failing silently in the background for the same reason as the first type of call and just returning 'Failed'


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>