How do you resolve a virtual path to a file under an OWIN host?

Paul Turner picture Paul Turner · Jul 4, 2014 · Viewed 15.1k times · Source

Under ASP.NET and IIS, if I have a virtual path in the form "~/content", I can resolve this to a physical location using the MapPath method:

HttpContext.Server.MapPath("~/content");

How can you resolve a virtual paths to a physical location under an OWIN host?

Answer

TN. picture TN. · Sep 8, 2014

You may use AppDomain.CurrentDomain.SetupInformation.ApplicationBase to get root of your application. With the root path, you can implement "MapPath" for Owin.

I do not know another way yet. (The ApplicationBase property is also used by Microsoft.Owin.FileSystems.PhysicalFileSystem.)