Abp 框架 Blazor UI 404 Notfound 页面

Abp framework Blazor UI 404 Notfound page

我正在使用ABP框架blazorUI,我需要自定义404未找到页面,我该怎么做?

您需要覆盖 Volo.BasicTheme\src\Volo.Abp.AspNetCore.Components.Web.BasicTheme\Themes\Basic\App.razor 文件

解决方案:

简单的方法是获取 BasicTheme 模块源代码 abp add-module Volo.BasicTheme --with-source-code --add-to-solution-file

然后手动编辑文件 <YourSolutionFolder>\modules\Volo.BasicTheme\src\Volo.Abp.AspNetCore.Components.Web.BasicTheme\Themes\Basic\App.razor

示例:

@using Microsoft.Extensions.Options
@using Volo.Abp.AspNetCore.Components.Web.Theming.Routing
@inject IOptions<AbpRouterOptions> RouterOptions
<CascadingAuthenticationState>
    <Router AppAssembly="RouterOptions.Value.AppAssembly"
            AdditionalAssemblies="RouterOptions.Value.AdditionalAssemblies">
        <Found Context="routeData">
            <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
                <NotAuthorized>
                    @if (!context.User.Identity.IsAuthenticated)
                    {
                        <RedirectToLogin />
                    }
                    else
                    {
                        <p>You are not authorized to access this resource.</p>
                    }
                </NotAuthorized>
            </AuthorizeRouteView>
        </Found>
        <NotFound>
            <LayoutView Layout="@typeof(MainLayout)">
                *** <p>New not found Page Content.</p> ***
            </LayoutView>
        </NotFound>
    </Router>
</CascadingAuthenticationState>