I haven't found a method yet that will do it, but this will effectively output the same format:
var internalUrl = $"~/link/{block.ContentGuid.ToString().Replace("-", "")}.aspx";
Hi Ian,
I would be interested in understanding what you are trying to do, why do you want to create a url for a block, as they are not routable?
Andy
Have a look at my blogpost for varius ways of obtaining the URL.
https://www.gulla.net/no/blog/content-url-with-or-without-shortcut/
My favorite:
SELECT LinkURL
FROM tblContentLanguage
WHERE fkContentID = 1337
The official way is to use IPermanentLinkMapper to get the PermanentLinkMap from ContentReference (_permanentLinkMapper.Find(contentLink). PermanentLinkMap contains PermanentLinkUrl which should be what you are looking for :)
@Andrew - The short of it is that I'm allowing editors to link to certain block types from within the Create Link dialog window, which will result in a dynamic modal popup window on the front-end. In doing so, I need to override the UrlResolver so that the correct URLs are generated on both the front-end as well as the Epi admin.
If I have a valid ContentReference instance pointing to a block, how can I go about getting the internal URL for that block? Example: ~/link/dd34112844b94401a0c66ed8106ae4cb.aspx