17

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>

enter image description here

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

halfer
  • 18,701
  • 13
  • 79
  • 158
Ibanez1408
  • 3,275
  • 8
  • 31
  • 75

4 Answers4

10

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

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

enter image description here

Konstantin Salavatov
  • 3,925
  • 2
  • 23
  • 24
10

Warning! The .vs folder contains all the data that VS gathered about the projects in your solution, the opened files, debug. You will lose all that!

Close Visual Studios and delete the .vs hidden folder in the root of your solution.

Start up your project and the error's will be gone.

Katey
  • 141
  • 2
  • 6
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.

enter image description here

ahmetsse
  • 61
  • 4
  • I've had to do this twice now and twice this has helped me because it reminded me to check for NuGet updates, which fixed the problem. – Tod Sep 23 '20 at 13:24
0

Looks like it's an IntelliSense issue of the VisualStudio, see: https://developercommunity.visualstudio.com/content/problem/770539/visual-studio-lost-intellisense-for-blazor-compone.html

Alex
  • 999
  • 1
  • 10
  • 11