c# - 在 Blazor 应用程序中使用意外名称进行标记?
问题描述
尝试在我的 blazor Web 程序集应用程序中建立用户帐户并构建身份验证元素。
但是,两个组件有错误:
Found markup element with unexpected name 'xxxxxxxxxxxxxxxx'
两个有问题的组件是 AuthorizeRouteView 和 CascadingAuthenticationState。
我的代码:
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<CascadingAuthenticationState>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</CascadingAuthenticationState>
</NotFound>
</Router>
任何线索可能是什么问题?
解决方案
尝试以下设置。请注意,NotAuthorized 属性元素中有一个名为 RedirectToLogin 的元素。这是您应该定义的 Razor 组件的名称(RedirectToLogin.razor 文件名),并且可能需要在 _Imports.razor 文件中更新其命名空间(例如:@using OpenIDConnectSample.Shared)。
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData"
DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<RedirectToLogin />
</NotAuthorized>
<Authorizing>
Wait...
</Authorizing>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
推荐阅读
- alignment - 表格单元格内的垂直图形对齐
- html - HTML 表单(引导程序)有错误的缩进
- javascript - 不断收到 TypeError:.map 不是函数
- python - python 3中的用户名和密码迭代
- android - Logstat 状态没有连接设备。有什么办法可以改正
- python-3.x - Seaborn 绘制值列表与其索引
- excel - 如何根据多个值检查一个值是部分、完整还是无
- google-sheets - 通过 Google 表单的最新时间戳输入更新 Google 表格中的单元格
- r - 从闪亮的R列表中分配selectInput选项
- pine-script - 将中点添加到枢轴高低指标