Try our conversational search powered by Generative AI!

It is not possible to use UrlResolver to get Public Url to something that does not have a template (e.g. a folder)

Found in

Release 7.5

Created

Nov 27, 2013

Updated

Apr 11, 2014

Area

Falcon/CMS/Core/Routing

State

Closed, Fixed and Tested


Steps to reproduce

The UrlResolver will check if a content item has a template and if not return null as Url. 

This is fine when generating URls for UI (like that container pages should not have URL in UI).
However there is cases where you need the url anyway (e.g. to use as a base path when comparing/constructin other urls). For example in ContentChannelHandler there is a property ContentAssetsRootPath that is use to verify if a virtualpath is under content assets root path. 

Steps to reproduce (requires coding):

var url = ServiceLocator.Current.GetInstance<UrlResolver>().GetUrl(SiteDefinition.Current.ContentAssetsRoot)
 
note that it will return null since there is no template.

After fix, you can call:
 
var url = ServiceLocator.Current.GetInstance<UrlResolver>().GetUrl(SiteDefinition.Current.ContentAssetsRoot, null, new VirtualPathArguments() { ValidateTemplate = false } )
 
to get the url for the folder despite that there is no template (and cannot be browsed to of course).