Search code examples
c#sitecoresitecore7

Sitecore LinkManager ExpandDynamicLinks does not resolve the site URL


I am having a problem with the ExpandDynamicLinks in Sitecore.

I am using the following method passing true for siteResolving. The problem is the site is not being resolved as promissed.

bodyExpandedLinks = Sitecore.Links.LinkManager.ExpandDynamicLinks(email.Body.Value, true);

I did set in my provider to never resolve the site because that is what I want for the whole site except for this email body above.

 alwaysIncludeServerUrl="false"

Does anybody know how to force that?

Thank you...


Solution

  • one option might be to check if AlwaysIncludeServerUrl is set to False before your call to ExpandDynamicLinks. If it's False you can explicitly call Sitecore.Links.UrlOptions.DefaultOptions.AlwaysIncludeServerUrl = true and then set it back to False after you have called ExpandDynamicLinks.