ASP.NET Core change AccessDenied route
For similar problems into an ASP.NET Core 2.x web app, if the authentication is made with Azure AD /OpenID Connect, you can change the route in this way.
services.AddAuthentication(options =>...)
.AddOpenIdConnect(options =>...)
.AddCookie(options =>
{
options.AccessDeniedPath = "/path/unauthorized";
options.LoginPath = "/path/login";
});
Try
services.AddIdentity<ApplicationUser, IdentityRole>(op=>op.Cookies.ApplicationCookie.AccessDeniedPath = new PathString("/InactiveSponsor"))
.AddEntityFrameworkStores<SponsorContext>()
.AddDefaultTokenProviders();
Or
services.Configure<IdentityOptions>(opt =>
{
opt.Cookies.ApplicationCookie.LoginPath = new PathString("/aa");
opt.Cookies.ApplicationCookie.AccessDeniedPath = new PathString("/InactiveSponsor");
opt.Cookies.ApplicationCookie.LogoutPath = new PathString("/");
});