I am developing an ASP.NET MVC 6 Web API application with an AngularJs interface.
When I leave a session before a decade, or I try to invoke a web API action unauthorized, I expect to get a status code 401. Instead, I get 302 and try to redirect the default login path ("/ Account / Login").
So I need to handle this in Angular.
From other forum posts here and googling, I found that some people solved their problems using startup.cs:
services.Configure<CookieAuthenticationOptions>(options => { options.LoginPath = PathString.Empty; });
I was not lucky.
I use Identity as authentication and even add
services.ConfigureIdentityApplicationCookie(options => { options.LoginPath = PathString.Empty; });
does not give the expected result. ASP.NET docs offer this way to return 401.
Using 1.0.0-beta7 CLR x86, IIS Express.
angularjs asp.net-core-mvc unauthorized
Valerio
source share