- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我一直在关注this tutorial用于在我的 blazor 客户端应用程序(托管的 asp.net 核心)上实现授权/身份验证。一切正常,直到我开始在客户端工作(the tutorial 中的“配置客户端 Blazor”副标题)。我已经成功安装了 Blazored.LocalStorage nuget 包。但我未能将“CascadingAuthenticationState”和“NotFoundContent”组件添加到我的 App.razor 文件中。编译器看不到这些组件并要求添加 using 指令。
这是 _Imports.razor:
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using Musical_WebStore_BlazorApp.Client
@using Musical_WebStore_BlazorApp.Client.Shared
@using Microsoft.AspNetCore.Authorization
@using Blazored.LocalStorage
这是不工作的 App.razor(我请求帮助我让它工作):
<CascadingAuthenticationState>
<Router AppAssembly="typeof(Program).Assembly">
<NotFoundContent>
<p>Sorry, there's nothing at this address.</p>
</NotFoundContent>
</Router>
</CascadingAuthenticationState>
这是正在运行的 App.razor(默认情况下我有它):
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
以下是项目的版本:
Blazor.Client (Microsoft.AspNetCore.Blazor nuget package): 3.0.0-preview9.19465.2
ASP.NET Core (Microsoft.AspNetCore.Blazor.Server nuget package): 3.0.0-preview9.19465.2
Shared: .NET Standard 2.0 library
我该如何解决这个问题?看起来这些组件应该默认可用。即使没有,我也无法在互联网上找到这些组件的 namespace 。
最佳答案
您需要从 NuGet 安装 Microsoft.AspNetCore.Components.Authorization
包。在我写那篇文章时,这个包还不存在。安装它并向 _Imports.razor
添加 using 后,您就可以开始使用了。
关于asp.net-core - CascadingAuthenticationState 和 NotFoundContent 标签在 Blazor 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58465964/
我有一个使用个人帐户设置的 Blazor 服务器端项目。我搭建了 AspNet.Core.Identity 页面并希望在其中一个 razor 页面中使用 Blazor 组件通过使用 标签助手。 我的
所以我一直在关注this tutorial用于在我的 blazor 客户端应用程序(托管的 asp.net 核心)上实现授权/身份验证。一切正常,直到我开始在客户端工作(the tutorial 中的
所以我一直在关注this tutorial用于在我的 blazor 客户端应用程序(托管的 asp.net 核心)上实现授权/身份验证。一切正常,直到我开始在客户端工作(the tutorial 中的
我是一名优秀的程序员,十分优秀!