I have a Razor Class Library that I've been using for months with .NetCore3 then .NetCore 5 without a problem.
After recently updating our blazor server application and our Razor Class Library to .NetCore 6 I've hit a problem loading the assets from the Razor Class Library.
The RCL is built and packaged via nuget and I can see the assets in the package, for example;
The web application has been updated to use a single program.cs and I'm using WebApplication.CreateBuilder()
with options for my setup.
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
ApplicationName = typeof(Program).Assembly.FullName,
ContentRootPath = Directory.GetCurrentDirectory(),
EnvironmentName = Environments.Development,
WebRootPath = ""
});
When loading these resources I'm getting a 404 error
<link href="_content/Blurred.Framework.Web.Shared/favicon.ico" type="image/x-icon" rel="icon" />
<link href="_content/Blurred.Framework.Web.Shared/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="_content/Blurred.Framework.Web.Shared/css/site.css" rel="stylesheet" />
I can also see the wwwroot folder and respective assets getting loaded into the application project in visual studio.
It feels like this is a configuration issue, rather than something significant that needs to change.
What are the correct settings for the ContentRootPath
or WebRootPath
?
Update
According to this I need to use app.UseStaticFiles();
which I have done, and also webBuilder.UseStaticWebAssets();
from within ConfigureWebHostDefaults
which isn't used in .NET6 :(