Configure authorization redirection

I am using Beta 4 and when I use the [Authorize] attribute it redirects to / account / login as I expected, but not to my url name. I can configure this in web.config, but I don't know where to configure it in ASP.NET 5. Any ideas?

+3


source to share


2 answers


Not sure if it helps, but I downloaded VS 2015 RC.

Ive created a new MVC 6 project and started (F5). unauthenticated , I tried to achieve ManageController

which is decorated with the attribute [Authorize]

.

Needless to say, I was redirected to view the account / login, but I couldn't find anywhere where this is configured.

I was able to add the following to the ConfigureServices()

method Startup.cs

:

services.Configure<CookieAuthenticationOptions>(options =>
    {
        options.LoginPath = new PathString("/Gazou/Index");
    });

      



A little higher:

services.AddMvc();

      

Then I created a new one GazouController

with a simple one Index IActionResult()

.

The reapplication tried to access again ManageController

, but this time I was redirected to a method of Index

mine GazouController

instead of the default behavior.

Hope this helps. Vince

+2


source


I think you haven't formatted it with code, so I can't see it, but this is what I found:



  services.Configure<CookieAuthenticationOptions>(opt =>
  {
    opt.LoginPath = PathString.FromUriComponent("/Auth/Login");
  });

      

0


source







All Articles