Why is the blazor css isolation not working?

Haneen Al-fakhry 5 Reputation points
2024-02-25T21:05:38.5766667+00:00

I have an AppLogin.razor component and its css file is AppLogin.razor.css. They are working fine. I have a UserLogin.razor component and its css file is UserLogin.razor.css. The working mechanism is as follows When you login from the AppLogin.razor component, it navigates to the UserLogin.razor component by NavigationManager route, but the problem is that it does not execute the css file for UserLogin.razor, but rather executes the css file for AppLogin.razor, even after moving to the UserLogin.razor component. What's the reason?

note : I have included this <link href="AssembleName.styles.css" rel="stylesheet">

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,562 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,328 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,470 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,392 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,550 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 59,966 Reputation points
    2024-02-26T16:50:10.05+00:00

    please read the docs until you understand how css isolation works:

    https://video2.skills-academy.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-8.0

    then use the browsers CSS debug tools to see why the isolation selectors are not work as you expected