Serve static files from folder other than wwwroot in .NET Blazor

Опубликовано: 22 Март 2026
на канале: Authorised Territory
505
13

Authorised Territory code examples - This .NET #blazor #tutorial shows how to set static folder from which assets files are served.
First, image file is added and css file is modified in wwwroot folder. The app is run and image displays as normal.
Next, the image and css files are moved to a new folder called Resources, outside of wwwroot folder.
Finally, in Program.cs file, default StaticFile middleware is modified in order to set new path where assets files are located and the app is run again. Image and css files are accessible to the app.