Reputation: 5078
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....?
Upvotes: 50
Views: 44924
Reputation: 1613
I have removed the .vs
rubbish folder. After that there is nothing I can do to make the C# extension in VS Code
to work again. Looks like the only way to solve that problem is to open the project with full Visual Studio
again
Upvotes: 0
Reputation: 3943
I had a similar issue. I found these entries about my "problem" component in my .csproj
file. After deleting them (VS closed) and re-open the solution, the error has been gone.
Upvotes: 1
Reputation: 571
The solution which works for me is the following:
Upvotes: 8
Reputation: 93
I had this issue with a MudBlazor component, in fact it did not see any MudBlazor component when you typed [Mud into the .razor file in the editor.
As far as I can tell, I was trying to use MudBlazor with .Net 8 and the latest version of MudBlazor has dependency listings for .Net 6 and .Net 7 but nothing listed for .Net 8
After downgrading my Target Framework to .Net 7 the MudBlazor components came back to life, strangely after switching back to .Net 8 they were still there.
Upvotes: 0
Reputation: 253
This issue went away for me after updating "Build Action" from "None" to "Content" for newly added razor component.
Upvotes: 11
Reputation: 32455
For .NET 6
Microsoft.AspNetCore.Components.Authorization
NuGet package is installed@using Microsoft.AspNetCore.Components.Authorization
to _Imports.razor fileUpvotes: 3
Reputation: 193
If I create a razor component as right click -> add new item -> razor component, then everything is ok. But if I copy-paste an existing razor component and do further work on it, then it creates the above stated issue.
Upvotes: 2
Reputation: 1295
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
Upvotes: 1
Reputation: 666
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.
Upvotes: 61
Reputation: 111
Upvotes: 4
Reputation: 4540
For me adding both references to _Imports.razor worked to solve same issue:
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
Upvotes: 22