0

我用 c# 编写了一个使用授权的 Wep Application ASP NET CORE 2.2。他们工作正常。现在,当访问被拒绝时,URL 将被重写,例如如下:

https://ebbwebdev.azurewebsites.net/Account/AccessDenied?ReturnUrl=%2FTelemetries

显示的页面是错误404。

我正在使用 ASP.NET Core 标识。

如何将被拒绝的访问重定向到自定义页面?

谢谢你的合作。

4

2 回答 2

1

您可以简单地执行以下操作:

public void ConfigureServices(IServiceCollection services)
{

    services.ConfigureApplicationCookie(options =>
    {
        options.AccessDeniedPath = "/YourCustomAccessDeniedPath";

    });

}
于 2019-09-29T02:29:07.620 回答
1

尝试如下配置IdentityOptionsStartup

services.Configure<IdentityOptions>(opt =>
{
    opt.Cookies.ApplicationCookie.LoginPath = new PathString("/yourcustompage");
});
于 2019-09-29T02:14:20.640 回答