Hello,
I missed the Server.MapPath in .NET core. It is useful to get the physical path from a virtual directory in IIS.
When using blazor locally I also prefer to use the local IIS.
Fortunately this package exists, : install-package Microsoft.Web.Administration
Combined with System.Runtime.Caching, we can achive it by using:
public static string getIISContentPath() { var cache = new MemoryCache(new MemoryCacheOptions()); var strReturn = cache.GetOrCreate("getIISContentPath",entry => { ServerManager manager = new ServerManager(); var poolName = Environment.GetEnvironmentVariable("APP_POOL_ID", EnvironmentVariableTarget.Process); Site defaultSite = manager.Sites[poolName]; Application reports = defaultSite.Applications[0]; VirtualDirectory reportDir = reports.VirtualDirectories.FirstOrDefault(c => c.Path.ToLower() == "/content"); return reportDir.PhysicalPath; }); return strReturn; }