ASP.NET CORE 2.2授权错误重定向页面 [英] ASP.NET CORE 2.2 authorization error redirect page

查看:67
本文介绍了ASP.NET CORE 2.2授权错误重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用c#编写了一个使用授权的Wep应用程序ASP NET CORE 2.2.他们工作正常.现在,如果拒绝访问,则将URL重写如下:

I wrote a Wep Application ASP NET CORE 2.2 in c# which uses the authorization. They work properly. When access is denied now the url is rewritten for example as follows:

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

,显示的页面是错误404.

and the page displayed is Error 404.

我正在使用ASP.NET Core身份标识.

I'm using ASP.NET Core Identity.

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

How can I redirect access denied to a custom page?

感谢您的合作.

推荐答案

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

You can simply do as follows:

public void ConfigureServices(IServiceCollection services)
{

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

    });

}

这篇关于ASP.NET CORE 2.2授权错误重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆