Open Closed

Override App.razor in a Blazor Server application template #4796


User avatar
0
ccernat created
  • ABP Framework version: v7.1.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hello,

How can I override App.razor in a ABP Blazor Server app template?

Thank you!


2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    @using Microsoft.Extensions.Options
    @using Microsoft.Extensions.Localization
    @using global::Localization.Resources.AbpUi
    @using Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.ApplicationLayout
    @using Volo.Abp.AspNetCore.Components.Web.Theming.Routing
    @using Volo.Abp.DependencyInjection
    @inject IOptions<AbpRouterOptions> RouterOptions
    @inject IStringLocalizer<AbpUiResource> UiLocalizer
    @inherits Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.App
    @attribute [Dependency(ReplaceServices = true)]
    @attribute [ExposeServices(typeof(Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.App))]
    <CascadingAuthenticationState>
        <Router AppAssembly="RouterOptions.Value.AppAssembly"
                AdditionalAssemblies="RouterOptions.Value.AdditionalAssemblies">
            <Found Context="routeData">
                <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(DefaultLayout)">
                    <NotAuthorized>
                        @if (context.User?.Identity?.IsAuthenticated == false)
                        {
                            <RedirectToLogin/>
                        }
                        else
                        {
                            @* Temporary removed since it makes a flicker effect on page refresh *@
                            @* <ErrorView
                                Title="@UiLocalizer["403Message"]"
                                HttpStatusCode="403"
                                Message="@UiLocalizer["403MessageDetail"]"/> *@
                        }
                    </NotAuthorized>
                </AuthorizeRouteView>
            </Found>
            <NotFound>
                <LayoutView Layout="@typeof(DefaultLayout)">
                    <Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.ErrorView
                        Title="@UiLocalizer["404Message"]"
                        HttpStatusCode="404"
                        Message="@UiLocalizer["404MessageDetail"]"/>
    
                    <h1>test222</h1>
                </LayoutView>
            </NotFound>
        </Router>
    </CascadingAuthenticationState>
    
    

  • User Avatar
    0
    ccernat created

    tks a lot!

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15