Created
February 23, 2012 20:46
-
-
Save Stephanvs/1894955 to your computer and use it in GitHub Desktop.
Url Helper for ASP.NET MVC hosted on AppHarbor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string ToPublicUrl(this UrlHelper urlHelper, Uri relativeUri) | |
{ | |
var httpContext = urlHelper.RequestContext.HttpContext; | |
var uriBuilder = new UriBuilder | |
{ | |
Host = httpContext.Request.Url.Host, | |
Path = "/", | |
Port = 80, | |
Scheme = "http", | |
}; | |
if (httpContext.Request.IsLocal) | |
{ | |
uriBuilder.Port = httpContext.Request.Url.Port; | |
} | |
return new Uri(uriBuilder.Uri, relativeUri).AbsoluteUri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment