Wednesday, July 13, 2016

How to get friendly URL of the current page in Sharepoint

string url = HttpContext.Current.Request.Uri.OriginalString;
TaxonomyNavigationContext class ontains several properties which will help you to work with friendly URLs programmatically,
For Example:
 HasFriendlyUrl and ResolvedDisplayUrl (all properties can be found here).
you can get friendly URL using the following code:

  string url = "";
if (TaxonomyNavigationContext.Current != null &&
     TaxonomyNavigationContext.Current.HasFriendlyUrl)
 {
     url = SPUtility.GetFullUrl(SPContext.Current.Site,
          TaxonomyNavigationContext.Current.ResolvedDisplayUrl);
  }

No comments:

Post a Comment