【问题标题】:Customizing the 'Authorizing...' message (top left corner) of a Blazor Wasm app自定义 Blazor Wasm 应用程序的“授权...”消息(左上角)
【发布时间】:2020-12-30 18:06:13
【问题描述】:

加载 Blazor WebAssembly 应用程序时,它首先下载 blazor.webassembly.js 和应用程序的所有 .NET 程序集。在加载所有内容之前,它会显示一条加载消息。我们可以在wwwroot/index.html中轻松更改此消息

<body>
<!-- ???? Here -->
<app>Loading...</app>

<div id="blazor-error-ui">
    An unhandled error has occurred.
    <a href="" class="reload">Reload</a>
    <a class="dismiss">????</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>

而且,如果我们使用身份验证(CascadingAuthenticationStateAuthorizeRouteView、...)保护您的应用程序,我们还会在左上角看到“正在授权...”。

我的问题是:如何自定义此消息?我什么也没看到。

【问题讨论】:

    标签: blazor webassembly


    【解决方案1】:

    App.razor 你可以:

    ...
    <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
        <Authorizing>
            Some other authorizing message...
        </Authorizing>
        <NotAuthorized>
            @if (!context.User.Identity.IsAuthenticated)
            {
                <RedirectToLogin />
            }
            else
            {
                <p>You are not authorized to access this resource.</p>
            }
        </NotAuthorized>
    </AuthorizeRouteView>
    ...
    
    

    【讨论】:

    猜你喜欢
    • 2021-05-14
    • 2020-12-09
    • 2021-02-24
    • 2020-09-23
    • 2019-10-21
    • 2022-10-22
    • 2020-09-23
    • 2021-01-04
    • 1970-01-01
    相关资源
    最近更新 更多