.net core 我该如何更改“的”;授权……”;刷新Blazor PWA应用程序时出现的消息?
使用浏览器刷新刷新asp net托管的BLAZOR Progressive Web应用程序时,PWA应用程序将执行身份验证往返。在此时间跨度内,main content div显示文本:“授权…”。这个消息来自哪里?我的目标是在显示此消息的同时显示微调器边框,以便用户体验动画。以下是我所知道的:.net core 我该如何更改“的”;授权……”;刷新Blazor PWA应用程序时出现的消息?,.net-core,blazor,progressive-web-apps,.net Core,Blazor,Progressive Web Apps,使用浏览器刷新刷新asp net托管的BLAZOR Progressive Web应用程序时,PWA应用程序将执行身份验证往返。在此时间跨度内,main content div显示文本:“授权…”。这个消息来自哪里?我的目标是在显示此消息的同时显示微调器边框,以便用户体验动画。以下是我所知道的: 在wwwroot的索引页中显示初始“加载…”消息 对于每个AutherizeView,授权部分可用于显示自定义消息 但我无法找到默认“授权…”消息的来源。有两个地方需要您的意图 首先是在你的App.
- 在wwwroot的索引页中显示初始“加载…”消息
- 对于每个AutherizeView,授权部分可用于显示自定义消息
但我无法找到默认“授权…”消息的来源。有两个地方需要您的意图 首先是在你的
App.razor
中。AuthorizeRouteView
有一个名为Authorizing
的属性,您可以在其中添加授权期间要显示的任何renderfragment
。是设置授权…
的行
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
<span>Your spinner goes here</span>
</Authorizing>
<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>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
您可以通过添加相应的RenderFragments
来更改整个模板,可以找到
下面是一个示例,其中每个片段都有一个非默认值
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action">
<LoggingIn>
<span>LoggingIn</span>
</LoggingIn>
<Registering>
<span>Registering</span>
</Registering>
<Registering>
<span>LoggingIn</span>
</Registering>
<UserProfile>
<span>UserProfile is loaded....</span>
</UserProfile>
<CompletingLoggingIn>
<span>CompletingLoggingIn</span>
</CompletingLoggingIn>
<LogInFailed>
<span>Login failed. Reason: @context</span>
</LogInFailed>
<LogOut>
<span>Logout from the application</span>
</LogOut>
<LogOut>
<span>CompletingLogOut</span>
</LogOut>
<LogOutFailed>
<span>Logout failed. Reason: @context</span>
</LogOutFailed>
<LogOut>
<span>LogOutSucceeded</span>
</LogOut>
</RemoteAuthenticatorView>
@code{
[Parameter] public string Action { get; set; }
}
@page”/authentication/{action}
@使用Microsoft.AspNetCore.Components.WebAssembly.Authentication
登录
登记
登录
用户配置文件已加载。。。。
完成记录
登录失败。原因:@context
从应用程序注销
完成注销
注销失败。原因:@context
注销成功
@代码{
[参数]公共字符串操作{get;set;}
}
有两个地方需要你的意图
首先是在你的App.razor
中。AuthorizeRouteView
有一个名为Authorizing
的属性,您可以在其中添加授权期间要显示的任何renderfragment
。是设置授权…
的行
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
<span>Your spinner goes here</span>
</Authorizing>
<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>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
您可以通过添加相应的RenderFragments
来更改整个模板,可以找到
下面是一个示例,其中每个片段都有一个非默认值
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action">
<LoggingIn>
<span>LoggingIn</span>
</LoggingIn>
<Registering>
<span>Registering</span>
</Registering>
<Registering>
<span>LoggingIn</span>
</Registering>
<UserProfile>
<span>UserProfile is loaded....</span>
</UserProfile>
<CompletingLoggingIn>
<span>CompletingLoggingIn</span>
</CompletingLoggingIn>
<LogInFailed>
<span>Login failed. Reason: @context</span>
</LogInFailed>
<LogOut>
<span>Logout from the application</span>
</LogOut>
<LogOut>
<span>CompletingLogOut</span>
</LogOut>
<LogOutFailed>
<span>Logout failed. Reason: @context</span>
</LogOutFailed>
<LogOut>
<span>LogOutSucceeded</span>
</LogOut>
</RemoteAuthenticatorView>
@code{
[Parameter] public string Action { get; set; }
}
@page”/authentication/{action}
@使用Microsoft.AspNetCore.Components.WebAssembly.Authentication
登录
登记
登录
用户配置文件已加载。。。。
完成记录
登录失败。原因:@context
从应用程序注销
完成注销
注销失败。原因:@context
注销成功
@代码{
[参数]公共字符串操作{get;set;}
}
App.razor
中的AuthorizeRouteView
的授权
。谢谢@just the bennoIt是我的荣幸在应用程序中授权AuthorizeRouteView
的授权。谢谢你,我很高兴见到你