public static string MapPath (string virtualPath)
{
if (virtualPath == null || virtualPath == "")
throw new ArgumentNullException ("virtualPath");
HttpContext context = HttpContext.Current;
HttpRequest req = context == null ? null : context.Request;
if (req == null) // ADDED for Orchard
{
var pp = HostingEnvironment.ApplicationPhysicalPath;
String vp=virtualPath;
if (vp.IndexOf("~/") == 0)
{
vp = pp + virtualPath.Substring(2);
}
// TODO: if not "~/" ???? then what?
return vp;
} // END added for Orchard
else
return req.MapPath (virtualPath);
}