N2CMS extension methods for generating LinkedIn share link
Created
May 15, 2012 23:59
-
-
Save DejanMilicic/2706133 to your computer and use it in GitHub Desktop.
N2CMS : Link for sharing content on LinkedIn
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 class N2Extensions | |
{ | |
public static string FullUrl(this N2.ContentItem item) | |
{ | |
return HttpContext.Current.Request.Url.GetBaseUri().OriginalString + item.Url; | |
} | |
} |
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 class UriExtensions | |
{ | |
/// <summary> | |
/// Extracts the base URL from a <see cref="Uri"/>. | |
/// </summary> | |
/// <param name="uri">Specifies the URI from which to extract the base URL.</param> | |
/// <returns>A base url, for example http://www.foobar.com:8080</returns> | |
public static Uri GetBaseUri(this Uri uri) | |
{ | |
return new Uri(string.Format("{0}{1}{2}", uri.Scheme, Uri.SchemeDelimiter, uri.Authority)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment