using System; namespace System.Web.Mvc { public static partial class Html { public static string Resolve(this HtmlHelper helper, string virtualUrl) { if (!virtualUrl.StartsWith("~/")) return virtualUrl; virtualUrl = virtualUrl.Remove(0, 2); string applicationPath = helper.ViewContext.HttpContext.Request.ApplicationPath; if(string.IsNullOrEmpty(applicationPath) || !applicationPath.EndsWith("/")) { applicationPath = applicationPath + "/"; } return applicationPath + virtualUrl; } } }