Load Static Assets From Non-Public Directory in ASP.Net Core

ebeeraheem

View Profile
65 views
Aug 21, 2025

Add the file to a directory other than the default public directory (i.e. wwwroot)

Right-click on the file, select properties and set

Copy to Output Directory: Copy if newer

For example:  “Persistence/SeedData/logo.png”

Then retrieve it like so

var logoPath = Path.Combine(AppContext.BaseDirectory, "Persistence", "SeedData", "logo.png");