StaticWebAssets and localhost

We’re developing an aspnet core website with webapi backend all on a cloud platform. The auth part is implemented with openidconnect and cookies. Every tab is a new application to reduce release and test times. For the website / applications we have a razor class library that contains the main layout. See all posts in this series cloudnative

Debugging the application on localhost showed HTTP404 when loading the css and js files from the razor class library. Turns out we needed to configure UseStaticWebAssets when running on localhost. This is a feature that is set when the environment is development, but since we use localhost we had to include this code.

if(builder.Environment.IsLocalhost())
{
    builder.WebHost.UseStaticWebAssets();
}
Unknown's avatar

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , . Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.