Asp.net core Identity successful login redirecting back to login page

后端 未结 6 927
长情又很酷
长情又很酷 2020-11-30 12:38

I have a problem where the asp.net identity framework is redirecting the user back to the login page after they have logged in successfully.

This is using the stand

6条回答
  •  抹茶落季
    2020-11-30 13:18

    I tried many suggestions and finally what worked for me was: First, in your ConfigureServices class within "Startup.cs" add this

    services.AddMvc().AddMvcOptions(Mvcoption => {
                Mvcoption.EnableEndpointRouting = false;
            });
    

    The above code should come after this:

    services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
                    .AddCookie(options =>
                    {
                        options.LoginPath = "/Home/Login";
    
    
                    });
    

    Just in case you don't have the above two codes, try including them in your mvc application. Then you can go ahead and add these in your Configure method.

    app.UseAuthentication();
            app.UseMvc();
    

    Hope it works now.

    Happy coding!

提交回复
热议问题