简体   繁体   English

使用Microsoft.AspNetCore.Authentication.AzureADB2C.UI时如何覆盖/替换错误页面处理?

[英]How to override / substitute Error Page handling when using the Microsoft.AspNetCore.Authentication.AzureADB2C.UI?

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. 我在ASP.Net Core 2.2 MVC Web App中使用Azure AD B2C .Net核心Microsoft.AspNetCore.Authentication.AzureADB2C.UI库(使用NuGet安装)。

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? 有谁知道如何覆盖错误处理和/或该库的任何其他页面?

This is the page (github) that gets returned for any Azure B2C errors. 这是针对任何Azure B2C错误返回的页面(github)。 https://github.com/aspnet/AspNetCore/blob/master/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml 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();
}

Put this in your Startup.Configure() method: 把它放在你的Startup.Configure()方法中:

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. 重定向到您想要的任何页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 安装 Microsoft.AspnetCore.Authentication.AzureADB2C.UI 后无法加载 Microsoft.AspNetCore.Razor.Runtime - Cannot Load Microsoft.AspNetCore.Razor.Runtime after installing Microsoft.AspnetCore.Authentication.AzureADB2C.UI Authentication.AzureADB2C.UI - 如何自定义错误页面 - .Net Core 3.1 - Authentication.AzureADB2C.UI - How to customize Error Page - .Net Core 3.1 如何使用 Microsoft.AspNetCore.Authentication 在 C# 中设置 OpenIdConnect 客户端身份验证方法(从配置作为参数)? - How to set OpenIdConnect Client Authentication Method (from a config as a parameter) in C# using Microsoft.AspNetCore.Authentication? “Microsoft.AspNetCore.Components.WebAssembly.Authentication.BaseAddressAuthorizationMessageHandler”类型没有服务错误 - No service for type ' Microsoft.AspNetCore.Components.WebAssembly.Authentication.BaseAddressAuthorizationMessageHandler' Error Kestrel 使用 Microsoft.AspNetCore.Authentication.Negotiate 与多个用户 - Kestrel using Microsoft.AspNetCore.Authentication.Negotiate with multiple users 迁移到 Swashbuckle.AspNetCore 版本 5 时,Swagger UI 中的不记名身份验证 - Bearer authentication in Swagger UI, when migrating to Swashbuckle.AspNetCore version 5 使用Microsoft.AspNetCore.NodeServices调用JS文件时,获取节点调用超时错误 - Getting Node invocation timed out error when invoking JS file using Microsoft.AspNetCore.NodeServices AspNetCore Web Api 微软账户认证 - AspNetCore Web Api Microsoft Account Authentication 协商身份验证和 Microsoft.AspNetCore.Mvc.Testing - Negotiate authentication and Microsoft.AspNetCore.Mvc.Testing 在使用 LanguageExt 时使用替代/默认返回来处理“失败”? - Using a substitute/default return on handling a “failure” when using LanguageExt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM