Tuesday, June 3, 2014

ASP.NET Web API: Map a virtual path to a physical path

ASP.NET always had the Server.MapPath option. This allowed you to translate a virtual path like “~/Content/Images” to an absolute path on the file system. The question is how can do this in Web API without tying yourself to ASP.NET(which makes self hosting a no-go).

The correct way seems to be the HostingEnvironment.MapPath method. Sounds good to me…