Search code examples
blazorabp-framework

Abp framework Blazor UI 404 Notfound page


I'm using ABP framework blazor UI and I need to customize the 404 not found page, how can I do it?


Solution

  • You need to override Volo.BasicTheme\src\Volo.Abp.AspNetCore.Components.Web.BasicTheme\Themes\Basic\App.razor File

    Solution:

    easy way to do this is to fetch BasicTheme Modules source code abp add-module Volo.BasicTheme --with-source-code --add-to-solution-file

    Then edit the file manually in <YourSolutionFolder>\modules\Volo.BasicTheme\src\Volo.Abp.AspNetCore.Components.Web.BasicTheme\Themes\Basic\App.razor

    example:

    @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>