public static string ResolveAbsoluteUrl(string relativePath)
{
if (relativePath[0] != '~') return relativePath;
string appPath = HttpContext.Current.Request.ApplicationPath == "/"
? "/"
: HttpContext.Current.Request.ApplicationPath + "/";
return HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + appPath + relativePath.Substring(2);
}
}