Bonjour,
La fonctionnalité Server.MapPath n'existe pas en .NET core. Elle peut s'avérer utile pour obtenir le chemin physique à partir d'un répertoire virtuel.
Quand je travaille en local avec Blazor je préfère également utiliser IIS.
Heureusement, il existe ce package nuget: install-package Microsoft.Web.Administration
Et avec System.Runtime.Caching, nous pouvons utiliser le code suivant:
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; }