Search code examples
asp.net-corevisual-studio-2019blazorrazor-class-library

BlazorWebAssembly 5.0 does not load static assets from Razor class library


Note: This is not a duplicate.

After upgrading to .Net Core 5, in BlazorWebAssembly the static assets(like .js or .css) from other class libraries(Razor class library projects) are not being served and face a 404 http status.

To test this I started with the default template example and added a Razor class library to it.I added .css file (test1.css) and as you can see the .css is not accessible. The same issue happened to my other projects.

(I have tested with both Visual Studio 2019 16.8.1 and also 16.9.0 preview 1)

enter image description here

resource not found :

enter image description here


Solution

  • You also have to: right click on the Dependencies folder, and select Add Project Reference..., and then tick the check-box for RazorClassLibrary1