Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net 5 mvc 6 loginUrl change path

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, where I have created a loginController. This loginController requires you are Authorize'd. But when trying to reach the pages, I am redirected to "/Account/Login".

How would I go about changing this path to "/AREA/Login/Index"?

like image 639
jan Avatar asked Mar 07 '15 17:03

jan


2 Answers

services.AddIdentity<ApplicationUser, ApplicationRole>(options =>
{
    options.Cookies.ApplicationCookie.LoginPath = "/Login";
});
like image 70
Jhonattan Avatar answered Sep 19 '22 17:09

Jhonattan


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?

like image 23
Kiran Avatar answered Sep 22 '22 17:09

Kiran