When creating a new project in VS 2015 WebApplication, how would you go about changing the Redirect LoginUrl Path when not Authorize\'d?
I have created a new Area, w
services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
options.Cookies.ApplicationCookie.LoginPath = "/Login";
});
This is basically the same as Jhonattan's answer, and it worked for me when the accepted answer didn't. The only difference is that if you don't have an ApplicationRole model, you can use IdentityRole (which ApplicationRole would inherit from).
Try doing the following:
services.Configure<CookieAuthenticationOptions>(options =>
{
options.LoginPath = new PathString("/<YOUR-AREA>/Account/Login");
});
Question: Did you decorate your controller with an [Area] attribute?
services.ConfigureIdentityApplicationCookie(options => {
options.LoginPath = "/AREA/Login/Index";
});
services.AddIdentity<ApplicationUser, ApplicationRole>(options =>
{
options.Cookies.ApplicationCookie.LoginPath = "/Login";
});