I can't use Control.ResolveUrl because I need to write the
conversion in a utility class.
However I know the current context.
How could I convert the URL to one usable by the user?
Lloyd,
Example Usage:
this.Label1.Text = GetFullUrl(HttpContext.Current,
"~/folder1/default.aspx");
returns
http://localhost/WebApp1/folder1/default.aspx
Note:
This method works with cookieless sessions.
public string GetFullUrl(HttpContext context, string relativeUrl)
{
return
Uri.UriSchemeHttp +
Uri.SchemeDelimiter +
context.Request.Headers["Host"].ToLower() +
context.Response.ApplyAppPathModifier(context.Request.ApplicationPath.Trim()).TrimEnd(new
char[] { '/' }) +
relativeUrl.TrimStart(new char[] { '~' });
}