Is there a URLHelper Method that follows/obeys the URL/SEO Settings?

Mark Schmidt asked on September 8, 2017 14:57

Is there a URLHelper Method that follows/obeys the Settings: UseURLsWithTrailingSlash, CaseRedirectEnum, Domain always www (or not), or the other settings?

I've looked at the decompiled DLL and I do not see anything that does this. Is there a method somewhere else that does this?

Kentico is doing it somewhere. I'd rather not rewrite all that logic if it exists already.

Thanks!

Recent Answers


Brenden Kehren answered on September 8, 2017 16:26

Hey Mark,

You may be able to take advantage of the CMS.URLRewritingEngine.URLRewriter class. Looking in the source it looks like there is a RewriteUrl(RequestStatusEnum status, string relativePath, ExcludedSystemEnum excludedEnum) method that calls all of those items you're looking for and returns a CMS.Helpers.RequestStatusEnum.

0 votesVote for this answer Mark as a Correct answer

Mark Schmidt answered on September 8, 2017 17:11

Thanks for looking into it @brenden-kehren, I appreciate your time.

Actually after digging into CMS\CMSModules\Content\CMSDesk\Properties\General.aspx.cs

And figuring out the Live URL. it looks like this is doing what I want.

pageUrl = Node.IsLink ? DocumentURLProvider.GetUrl(Node.NodeAliasPath) : DocumentURLProvider.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath);
pageUrl = URLHelper.ResolveUrl(pageUrl);
1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.