I Have an Asp.net Core Application with 2 areas, each area has its own login page. I use this code to redirect the user to the login page :
services.AddAuthentication(opt => { opt.DefaultScheme = "AdminAuth";})
.AddCookie("UserAuth", opt => { opt.LoginPath = "/User/Login"; opt.AccessDeniedPath = "/User/AccessDenied"; })
.AddCookie("AdminAuth", opt => { opt.LoginPath = "/Identity/Account/Login"; opt.AccessDeniedPath = "/Admin/Dashboard/AccessDenied"; });
after submitting the login form, the user login successfully but didn't go to the controller and come back to the login page. I Use these attributes for controllers : for Admin :
[Authorize(Roles = "Admin", AuthenticationSchemes = "AdminAuth")]
for Users :
[Authorize(Roles = "User", AuthenticationSchemes = "UserAuth")]
and for login, I am using this code :
_signInManager.PasswordSignInAsync(model.Username, model.Password, false, lockoutOnFailure: false);
