Authentication.AzureADB2C.UI-如何自定义错误页面-.Net Core 3.1

问题描述 投票:0回答:1

我有一个项目,我们正在使用程序包Microsoft.AspNetCore.Authentication.AzureADB2C.UI向Azure AD B2C进行身份验证。有时,如果会话过期或用户尝试直接从Azure AD B2C登录页面登录,则将显示以下错误页面[错误页面](https://github.com/dotnet/aspnetcore/blob/master/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml):Error page

但是,我想自定义此页面,但是我不知道该怎么做。

我已经通过替换Sign Out方法来定制AzureADB2C Controller以使用自定义的注销页面。但是,此控制器中没有“错误”方法。

有人可以告诉我要去的方向吗?

谢谢

c# asp.net-core azure-ad-b2c msal azure-authentication
1个回答
0
投票
if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}
else
{
    app.UseExceptionHandler("/Account/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.

    //Put this  method:
    app.UseRewriter(new RewriteOptions().Add(context =>
    {
        if (context.HttpContext.Request.Path == "/AzureADB2C/Account/SignedOut")
        {
            context.HttpContext.Response.Redirect("/Home/SignedOut");
        }
    }));
    app.UseHsts();
}
© www.soinside.com 2019 - 2024. All rights reserved.