Does the content type in question have a Page template (that is a template that can render the content in it's own request, like a WebForm, Mvc Controller or a HttpHandler)? By default UrlResolver checks that the content has a valid template otehrwise it returns null (since browsing the url will result in a 404).
You can however force the UrlResovler to generate urls even if there is no template for the content. You do this by using the overload that takes a VirtualPathArgument and there specify ValidateTemplate=false
Thanks Johan, the ContentType does have a template associated with it, but it's a template shared with other ContentTypes, if that makes any difference. I've tried what you suggested though and that did work, thanks for your help!
I have a page which returns the ContentType name and the Url of every page on our site, its purpose is for an automated test to browse each URL and check that a 200 is returned. This page uses the following to return its friendly URL:
public UrlBuilder GetFriendlyUrl(PageData page)
{
UrlBuilder urlBuilder = new UrlBuilder(page.LinkURL);
Global.UrlRewriteProvider.ConvertToExternal(urlBuilder, page.PageLink, Encoding.UTF8);
return urlBuilder;
}
In the case of one particular ContentType, this returns a url that looks like this, in every instance of that ContentType :
"/link/8b5c1e86a4b54110ba7a311a691de448.aspx?id=9485&epslanguage=en"
Other points to note...
I've tried a load of OOTB ways of getting external URL from ContentReference, PageData etc and nothing returns a nice, friendly URL. When our automated test tries to browse to this dodgy-looking URL, it fails.
Can anyone enlighten me as to what's going on here?
Cheers