I just struggled with this myself, and I came to the conclusion that in the latest version of "Microsoft.AspNetCore.Identity.EntityFrameworkCore" the dependency seems to be a problem .
I initially used version 1.1.0, but after a lot of debugging, logging owin middleware, etc., I came to the conclusion that I did nothing wrong. I checked:
- The authorized attribute worked and blocked the request
Added event handlers (OnRedirectToLogin), as shown below, to check the redirect URL (this was only for debugging)
options.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents { OnRedirectToLogin = evt => { evt.Response.Redirect(evt.RedirectUri);
Resolution : I rolled back my package to version 1.0.1, and then redirected it, as expected, to the URL defined in Startup.cs in the LoginPath setting
options.Cookies.ApplicationCookie.LoginPath = new PathString("/Auth/Login");
To clarify, this version works: Microsoft.AspNetCore.Identity.EntityFrameworkCore ":" 1.0.1 "
I am going to raise an error with the ASPNETCORE team to investigate version 1.1.0.
source share