3

How do you do the equivalent of Server.MapPath to find the path of a virtual directory with .Net Core?

franzo
  • 1,379
  • 1
  • 15
  • 30
  • 1
    The 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 Answers1

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
  • 5
    That 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
  • 2
    Same problem. That would not help to find the path to a mapped virtual directory. – franzo May 24 '17 at 22:11