private static string BuildAbsolute(string relativeUri)
{
// get current uri
Uri uri = HttpContext.Current.Request.Url;
// build absolute path
string app = HttpContext.Current.Request.ApplicationPath;
if (!app.EndsWith("/")) app += "/";
relativeUri = relativeUri.TrimStart('/');
// return the absolute path
return HttpUtility.UrlPathEncode(
String.Format("http://{0}:{1}{2}{3}",
uri.Host, uri.Port, app, relativeUri));
}
// generate a width URL
public static string ToWidth(string widthId)
{
return BuildAbsolute(String.Format("WidthAdmin.aspx?Width={0}", widthId));
}