How do you do the equivalent of Server.MapPath to find the path of a virtual directory with .Net Core?
Asked
Active
Viewed 5,628 times
3
-
1The answer appears to be that you simply shouldn't add virtual directories in IIS but instead map them programmatically, as discussed in https://stackoverflow.com/questions/36030121/virtual-directory-inside-of-asp-net-core-app-in-iis – franzo Nov 27 '18 at 01:20
1 Answers
1
Path.Combine(Env.WebRootPath, "SomePath")
is the equivalent..
Env.WebRootPath
where Env = environment, usually from the startup.cs
edit
what about this...
ApplicationEnvironment env = new ApplicationEnvironment();
env.ApplicationBasePath;
there is a big thread about this on the asp.net core mvc on GitHub not sure if this is what you are looking for or not.

mvermef
- 3,814
- 1
- 23
- 36
-
5That would find the path to a sub-folder, but it wouldn't find the path to a mapped virtual directory. – franzo May 23 '17 at 00:12
-
2Same problem. That would not help to find the path to a mapped virtual directory. – franzo May 24 '17 at 22:11