找到具有意外名称"Cascading AuthenticationState"的标记元素

找到具有意外名称

问题描述:

我在App.razor上遇到此错误:

I am getting this error on my App.razor:

找到具有意外名称的标记元素 'CascadingAuthenticationState'.如果打算将其作为组件, 为其命名空间添加@using指令

Found markup element with unexpected name 'CascadingAuthenticationState'. If this is intended to be a component, add a @using directive for it namespace

这是我正在使用的代码

<CascadingAuthenticationState>
    <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>
</CascadingAuthenticationState>

我正在使用Visual Studio 2019预览版,可以运行该应用程序,但是为什么级联中有红线...?谢谢您的帮助.

I am using Visual Studio 2019 preview and I can run the application but, why do I have the red line in the Cascading....? Thank you for your help.

对我来说,向_Imports.razor添加两个引用都可以解决同一问题:

For me adding both references to _Imports.razor worked to solve same issue:

@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization