A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

AI OnAI Off

Get URL of pages

Vote:
 

Hi,

through below code i m able to get all the pages which are located under the root page.

but i want to find the URL of all the pages.

i m not able to figure out how to get the URL.

could you please help me on this.

 PageDataCollection children = EPiServer.DataFactory.Instance.GetChildren(PageReference.RootPage);

#151665
Aug 03, 2016 11:04
Vote:
 

Something like this?

foreach (var child in children)
{
    var pageUrl = UrlResolver.Current.GetUrl(child);
}

If UrlResolver.Current is unavailable in EPiServer 7, then you could use something like this:

var pageUrl = ServiceLocator.Current.GetInstance<UrlResolver>().GetVirtualPath(pageLink);
#151669
Edited, Aug 03, 2016 12:41
error This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.