Why is the blazor css isolation not working?

Haneen Al-fakhry 10 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">

Developer technologies ASP.NET ASP.NET Core
Developer technologies .NET Blazor
Developer technologies .NET Other
Developer technologies ASP.NET Other
Developer technologies C#
{count} vote

1 answer

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

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

    https://learn.microsoft.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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.