title: A fully functional ASP.Net Core equivalent of Server.MapPath
body: <p>I'm looking for the ASP.Net Core (2.0) equivalent of System.Web's Server.MapPath.</p>
  
  <p>The general advice for this is to use IHostingEnvironment's ContentRootPath with Path.Combine</p>
  
  <p>e.g. </p>
  
  <pre><code>var fullPath = Path.Combine(_hostingEnvironment.ContentRootPath, localPath);
  </code></pre>
  
  <p>But if localPath may be a relative path (starting with '~'), that doesn't work. Or localPath might start with '/', or have no special prefix. If you look at the reference source for Server.MapPath (which seems to call Request.MapPath under the hood), it's a pretty complex beast, handling lots of scenarios. It uses another class VirtualPath, which in turn uses a UrlPath class. It sure doesn't just call Path.Combine.</p>
  
  <p>So I'm wondering if something as functionally rich has made it into ASP.Net Core yet.</p>
  
  <p>For the record, the reference source I was looking at for System.Web.HttpRequest was <a href="https://github.com/Microsoft/referencesource/blob/master/System.Web/HttpRequest.cs" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Thanks</p>