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,905 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,596 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,593 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,502 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,995 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 66,056 Reputation points
    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.