使用Microsoft.AspNetCore.Authentication.AzureADB2C.UI时如何覆盖/替换错误页面处理? [英] How to override / substitute Error Page handling when using the Microsoft.AspNetCore.Authentication.AzureADB2C.UI?

查看:131
本文介绍了使用Microsoft.AspNetCore.Authentication.AzureADB2C.UI时如何覆盖/替换错误页面处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ASP.Net Core 2.2 MVC Web App中使用Azure AD B2C .Net核心Microsoft.AspNetCore.Authentication.AzureADB2C.UI库(使用NuGet安装).

I am using the Azure AD B2C .Net core Microsoft.AspNetCore.Authentication.AzureADB2C.UI library (installed using NuGet) in a ASP.Net Core 2.2 MVC Web App.

我希望能够更改错误"页面,但是它会忽略任何自定义或开发人员模式错误页面.

I would like to be able to change the Error page, however it ignores any custom or Developer mode error pages.

有人知道我可以如何覆盖该库的错误处理和/或任何其他页面吗?

Does anyone know how I can override the error handling and/or any other pages of this library?

这是任何Azure B2C错误返回的页面(github).

This is the page (github) that gets returned for any Azure B2C errors. https://github.com/aspnet/AspNetCore/blob/master/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml

我已经创建了一个自定义错误页面,并且在启动时有以下内容.其他所有内容都将使用此自定义页面或默认的开发人员例外页面,具体取决于模式.

I have created a custom error page and have the following in my startup. Everything else uses either this custom page or the default developer exception page depending on mode.

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.
    app.UseHsts();
}

推荐答案

将其放在您的Startup.Configure()方法中:

Put this in your Startup.Configure() method:

app.UseRewriter(new RewriteOptions().Add(context =>
{
    if (context.HttpContext.Request.Path == "/AzureADB2C/Account/SignedOut")
    {
        context.HttpContext.Response.Redirect("/Home/SignedOut");
    }
}));

重定向到您想要的任何页面.

Redirect to whatever page you want.

这篇关于使用Microsoft.AspNetCore.Authentication.AzureADB2C.UI时如何覆盖/替换错误页面处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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