Search code examples
c#razorasp.net-core-mvc.net-6.0asp.net-core-6.0

Why does my ASP.NET Core MVC application add some identifier to HTML elements?


When running my new ASP.NET Core MVC application and viewing it in the browser, it seems ASP.NET Core added some kind of ID to some HTML elements.

I'm using .NET 6, and Razor .cshtml pages.

Why? And how to disable this?

Some kind of ID is added


Solution

  • It comes from Blazor CSS Isolation.

    You can disable it by adding <ScopedCssEnabled>false</ScopedCssEnabled> to your app's project file (.csproj).

    https://learn.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-8.0#disable-css-isolation