gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 08:01:06 25 4
gpt4 key购买 nike

我在 ASP.Net Core 2.2 MVC Web 应用程序中使用 Azure AD B2C .Net core Microsoft.AspNetCore.Authentication.AzureADB2C.UI 库(使用 NuGet 安装)。

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

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

这是针对任何 Azure B2C 错误返回的页面 (github)。 https://github.com/aspnet/AspNetCore/blob/master/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml

我创建了一个自定义错误页面,并在启动中包含以下内容。其他所有内容都使用此自定义页面或默认开发人员异常页面,具体取决于模式。

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() 方法中:

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

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

关于c# - 使用 Microsoft.AspNetCore.Authentication.AzureADB2C.UI 时如何覆盖/替换错误页面处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56391996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com