I am trying to use cookie validation in the main Asp.net application (dnx 4.5). Please note that since I have my own authentication mechanism (radius), I do not use the ready-made mechanism provided by basic authentication. When the user is not authenticated, I want to redirect to the login page.
I added the following code to Startup.cs. The idea should be redirected to the login controller if the user is not authenticated:
app.UseCookieAuthentication(options => { options.LoginPath = new Microsoft.AspNet.Http.PathString("/Login"); });
In my home controller, I have:
[Authorize] public IActionResult Index() { return View(); }
In my entry controller, I return a view corresponding to the radius entry form:
[AllowAnonymous] public IActionResult Index() { return View(); }
However, when I launch the application, redirection never occurs. Looking at the console output, I see the following:
warn: Microsoft.AspNet.Mvc.Controllers.ControllerActionInvoker[0] Authorization failed for the request at filter 'Microsoft.AspNet.Mvc.Filters.AuthorizeFilter'. info: Microsoft.AspNet.Mvc.ChallengeResult[1] Executing ChallengeResult with authentication schemes (). info: Microsoft.AspNet.Mvc.Infrastructure.MvcRouteHandler[2] Executed action ThingsProjectorWeb.Controllers.HomeController.Index in 0ms info: Microsoft.AspNet.Hosting.Internal.HostingEngine[2] Request finished in 0.0016ms 401
Any help on how to set this up correctly would be greatly appreciated. Thanks!
source share