Мар*_*вич 2 nuget nuget-package asp.net-core blazor blazor-client-side
因此,我一直在关注本教程,以在我的 blazor 客户端应用程序(托管 asp.net 核心)上实施授权/身份验证。一切正常,直到我开始在客户端工作(教程中的“配置客户端 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
Run Code Online (Sandbox Code Playgroud)
这是无法正常工作的 App.razor(我要求帮助我使其正常工作):
<CascadingAuthenticationState>
<Router AppAssembly="typeof(Program).Assembly">
<NotFoundContent>
<p>Sorry, there's nothing at this address.</p>
</NotFoundContent>
</Router>
</CascadingAuthenticationState>
Run Code Online (Sandbox Code Playgroud)
这是正在运行的 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>
Run Code Online (Sandbox Code Playgroud)
以下是项目的版本:
Blazor.Client(Microsoft.AspNetCore.Blazor nuget 包):3.0.0-preview9.19465.2
ASP.NET Core(Microsoft.AspNetCore.Blazor.Server nuget 包):3.0.0-preview9.19465.2
共享:.NET Standard 2.0 库
我该如何解决这个问题?看起来这些组件应该默认可用。即使没有,我也无法在 Internet 上找到这些组件的命名空间。
您需要Microsoft.AspNetCore.Components.Authorization从 NuGet安装包。在我写那篇文章的时候,这个包并不存在。一旦你安装了它并添加了一个使用_Imports.razor你就可以开始使用了。
| 归档时间: |
|
| 查看次数: |
2352 次 |
| 最近记录: |