Aspnetcore: Changes in css files imported in wwwroot in Blazor WASM app are not detected

Created on 30 Jun 2020  路  3Comments  路  Source: dotnet/aspnetcore

Describe the bug

Currently I have separate CSS files in wwwroot in a Blazor WASM client app whose new changes are not being loaded when using "dotnet run" on the project.

I have a Blazor WASM app that has an ASP.NET core backend. I use dotnet run and am not using IIS express. I have separate CSS files located in the client WASM's wwwroot which are imported to app.css using:
@import "mycustomfile.css
I have been making new changes to this file and relaunching the server, even rebuilding the project, and these changes are not being reflected in the content served to the browser. It seems that somewhere, an old version is being cached and has not updated. I am unsure of whether this is in the browser but I am using Chrome if that helps.

To Reproduce

  • Create a Blazor WASM app with ASP.NET backend hosting. (I used the Visual Studio IDE to do this).
  • Create a separate CSS file in wwwroot and import this file using @import "custom.css"; and fill with test css.
  • Run the project with "dotnet run" or the ".Server" option in VS.
  • Modify the CSS file in some way.
  • Relaunch the project and see if those changes were actually made.

Further technical details

dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.301
 Commit:    7feb845744

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.301\

Host (useful for support):
  Version: 3.1.5
  Commit:  65cd789777

.NET Core SDKs installed:
  2.1.801 [C:\Program Files\dotnet\sdk]
  3.1.301 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

VS Version: 16.6.2

Author Feedback area-blazor blazor-wasm

Most helpful comment

Does ctrl f5 in the browser reload it for you?

All 3 comments

Does ctrl f5 in the browser reload it for you?

I have got the same issue and below is how I got it working -

Browser reload using shift+f5 or ctrl+f5

Yes this works great! Thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings