Skip to content

Instantly share code, notes, and snippets.

@mataprasad
Last active April 22, 2018 14:35
Show Gist options
  • Save mataprasad/b1f20e924c8c2d98c5bbd7bbf96de57c to your computer and use it in GitHub Desktop.
Save mataprasad/b1f20e924c8c2d98c5bbd7bbf96de57c to your computer and use it in GitHub Desktop.
public static string GetFullPictureUrl(Guid? guid)
{
if (guid == null)
{
guid = Guid.Empty;
}
return ResolveServerUrl(System.Web.VirtualPathUtility.ToAbsolute("~/home/picture/" + guid.ToString()), false);
}
public static string ResolveServerUrl(string serverUrl, bool forceHttps)
{
if (serverUrl.IndexOf("://") > -1)
return serverUrl;
string newUrl = serverUrl;
Uri originalUri = System.Web.HttpContext.Current.Request.Url;
newUrl = (forceHttps ? "https" : originalUri.Scheme) +
"://" + originalUri.Authority + newUrl;
return newUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment