3
votes

In a Blazor WebAssembly .NET Core hosted application, after changing the {PROJECT NAME}.Client project name to "{PROJECT NAME}.Admin" (changing the client project name), scope identifies for CSS isolation in the {PROJECT NAME}.Admin.styles.css file and rendered objects in the DOM are different.


What I did

I created a .NET core hosted Blazor WebAssembly application with authentication. Ran the application. Worked fine.

Then I changed the project name of {PROJECT NAME}.Client project to "{PROJECT NAME}.Admin". And changed basically every where there was "Client" to "Admin".

  • Every where the name space was mentioned
  • The Client Folder in the project folder

Then I added the project references.

When I ran the project... This was the landing page.


The Issue

All the functionality works fine. All the components are rendered. But only Bootstrap styling is applied to the MainLayout and NavMenu components as they use CSS isolation. The isolated CSS files generated files scope identities aren't the same as what is rendered to the DOM.

Image of {PROJECT NAME}.Admin.styles.css file

Image of Rendered HTML

The page renders fine if I change the scope Identities manually. But it resets when I Run the application a next time.


I'm just play around with Blazor. So I'm expecting a fix to this problem rather than some alternate method or work around to do the styling. I'm new to online forums. Sorry for providing unnecessary information or providing less information. Please request any additional information needed.

Thanks! in advance.

2

2 Answers

4
votes

Deleting the CSS isolated files and creating them again from the beginning made it work! How ever rebuilding the solution or cleaning the solution did not work. Still no clue of what was going on.

1
votes

What worked for me was deleting the obj and bin folders, besides renaming the link to the css file to {AssemblyName}.styles.css. Setting it to ProjectName does not work if it differs from AssemblyName.

This way it was not necessary for me to delete and recreate the specific css files. Note: I'm using Blazor Server with ASP.NET 5