Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025

 


Article

Get culture specific relative URL of a page through API

« Go Back

Information

 
Article Number000097911
EnvironmentProduct: Sitefinity
Version: 8.x, 9.x, 10.x,11.x, 12.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description
How to get a relative URL of a page in sitefinity that also contains the multure component of the page in Sitefinity through API?

Expected results:
Default language: /page-1
French(FR): /fr/page-1 
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution
To get the relative URL of a page that has the culture component in it, please utilize the following sample code:
//Get the CurrentCulture details
var currentCulture = Thread.CurrentThread.CurrentCulture;
UrlLocalizationService s = ObjectFactory.Resolve<UrlLocalizationService>();

//Get the relative URL of a page in the current culture. Where "page" is a PageNode
var url = s.ResolveUrl(page.GetUrl(currentCulture), currentCulture);
url = VirtualPathUtility.ToAbsolute(url);
Workaround
Notes
Attachment 
Last Modified Date8/13/2019 6:03 PM