ASP.NET Core change AccessDenied route
<p>I'm having some trouble with routing AccessDenied, probably Login/Logout path as well. The project is a stripped default one with no more magic. Soo there exist a <code>Account</code> controller with an <code>AccessDenied()</code> method.</p>

<p>What I'm trying now is (this is the solution offered by the goods of the internet)</p>

<pre><code>services.Configure&lt;CookieAuthenticationOptions&gt;(options =&gt;
{
    options.LoginPath = new PathString("/");
    options.AccessDeniedPath = new PathString("/InactiveSponsor");
    options.LogoutPath = new PathString("/");
});
</code></pre>

<p>But that does absolutely no difference. So any ideas? Any idea on why don't it work and how to make it work.</p>

<p>Here is my Startup.cs</p>

<pre><code>public Startup(IHostingEnvironment env)
{
    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
        .AddEnvironmentVariables();

    if (env.IsDevelopment())
    {
        // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
        builder.AddApplicationInsightsSettings(developerMode: true);
    }
    Configuration = builder.Build();
}

public IConfigurationRoot Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddApplicationInsightsTelemetry(Configuration);

    string connection = "DefaultConnection";
    //services.AddDbContext&lt;SponsorContext&gt;(options =&gt; options.UseSqlServer(connection));
    services.AddDbContext&lt;SponsorContext&gt;(options =&gt; options.UseSqlServer(Configuration[$"Data:{connection}"]));

    services.AddIdentity&lt;ApplicationUser, ApplicationRole&gt;()
        .AddEntityFrameworkStores&lt;SponsorContext&gt;()
        .AddDefaultTokenProviders();


    services.AddMvc();


    services.AddAuthorization(options =&gt;
    {
        options.AddPolicy(Policies.RequireAdmin, policy =&gt; policy.RequireRole(Roles.Administrator));
        options.AddPolicy(Policies.IsSponsor, policy =&gt; policy.RequireRole(Roles.Sponsor));
        options.AddPolicy(Policies.IsSponsorOrAdmin, policy =&gt; policy.RequireRole(Roles.Administrator, Roles.Sponsor));
    });

    /*
     * AddTransient Different on each instance/use
     * AddScoped Different instance on a per request basis
     * AddSingleton Always the same instance
     */
    //DI
    services.AddScoped&lt;ManageUserRepository&gt;();
    services.AddScoped&lt;ISponsorManagement, SponsorRepository&gt;();
    services.AddScoped&lt;ISponsorRead, SponsorRepository&gt;();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();

    app.UseApplicationInsightsRequestTelemetry();

    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
        app.UseBrowserLink();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
    }

    app.UseApplicationInsightsExceptionTelemetry();

    app.UseStaticFiles();
    app.UseIdentity();


    app.UseMvc(routes =&gt;
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
}
</code></pre>