[英]ASP.NET CORE 2.2 authorization error redirect page
我在 c# 中編寫了一個使用授權的 Wep Application ASP NET CORE 2.2。 他們工作正常。 當現在拒絕訪問時,url 被重寫,例如如下:
https://ebbwebdev.azurewebsites.net/Account/AccessDenied?ReturnUrl=%2FTelemetries
顯示的頁面是錯誤404。
我正在使用 ASP.NET 核心標識。
如何將被拒絕的訪問重定向到自定義頁面?
謝謝你的合作。
嘗試在Startup
中配置IdentityOptions
,如下所示,
services.Configure<IdentityOptions>(opt =>
{
opt.Cookies.ApplicationCookie.LoginPath = new PathString("/yourcustompage");
});
您可以簡單地執行以下操作:
public void ConfigureServices(IServiceCollection services)
{
services.ConfigureApplicationCookie(options =>
{
options.AccessDeniedPath = "/YourCustomAccessDeniedPath";
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.