Skip to content

Instantly share code, notes, and snippets.

@underwhelmed
Created December 7, 2012 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save underwhelmed/4234575 to your computer and use it in GitHub Desktop.
Save underwhelmed/4234575 to your computer and use it in GitHub Desktop.
Convert a relative URL into an Absolute URL in .NET
public string ConvertRelativeUrlToAbsoluteUrl(string relativeUrl)
{
if (Request.IsSecureConnection)
return string.Format("https://{0}{1}", Request.Url.Host, Page.ResolveUrl(relativeUrl));
else
return string.Format("http://{0}{1}", Request.Url.Host, Page.ResolveUrl(relativeUrl));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment