November Happy Hour will be moved to Thursday December 5th.

Get content page from relative friendly url

Vote:
 

Hi

How can I get a content page from it's friendly relative url. e.g. /folder-one/folder-two/page/

Lee

#111966
Oct 21, 2014 15:06
Vote:
 
#111969
Oct 21, 2014 15:21
Vote:
 

Unfortunately that does work for me :(

I have the following example code:

var resolver = ServiceLocator.Current.GetInstance<UrlResolver>();
var urlBuilder = new UrlBuilder("http://site.com/page-one/");
var contentReference = resolver.Route(urlBuilder);

The site has a page named "Page-One", but the contentRefefrence is always null.

Is this something to do with routing, the site was a CMS6R2 site which has been upgraded to 7.5 (still web forms)

#111984
Oct 21, 2014 16:34
Vote:
 

After decompiling the UrlResolver I see my problem.

The code checks whether the host I am sending in is in the site definitions, if it isn't it returns null.

The Url I was browsing the site with was not in the site defintions hence the problem.

If I use the page path rather than the absoute url it works fine as it uses the default site defition.

#112001
Oct 22, 2014 9:48
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.