Found markup element with unexpected name 'Cascading AuthenticationState'

那年仲夏 提交于 2020-02-20 08:36:27

问题


I am getting this error on my App.razor:

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

This is the code I am using

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

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.


回答1:


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

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




回答2:


  1. Right Click Project
  2. Manage Nuget Packages
  3. Select "Microsoft.AspNetCore.Blazor" which you have already installed.
  4. Update with Latest stable version then...
  5. Update Latest preview again.



来源:https://stackoverflow.com/questions/58336875/found-markup-element-with-unexpected-name-cascading-authenticationstate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!