Broken Embeded Link


I am using a custom API to get a content block from CMS. I am making this call from a seperate website and manipulating a portion of the content. The result is rendering an embedded link invalid. The link's URL doesn't change and I am not manipulating the URL and do not understand why the embedded URL is not redirecting to the right page. 

I am very new to Episerver. Please, if possible, frame answers as simply as possible. 

Jan 14, 2016 23:18

Which Epi version are you using and how are you getting the XhtmlString property value that you use in the API result?

Jan 15, 2016 9:32

We are using episerver CMS 8.2

And this is the code I am using to pull the Xhtmlstring value

message =
.Replace("\n", "")
.Replace(baseAddress, "..")

Jan 15, 2016 16:32

To give more clarity in to what I am seeing, sometimes, the value to replace in the string will be "60" so I will replace "60" in the string with "60". In this situation the link works fine. But sometimes the [ValuetoReplacePartofTheStringWith] is "59" or "57" or something, so "60" gets replaced with "59". In this case the link is broken.

Here is an example of the strings"

Content Block in CMS, un manipulated:

"You are 60 days from x, please go to [link] to find out more"

Manipulated string with a replace value of "60":

"You are 60 days from x, please go to [link] to find out more" - Link works fine

Manipulated string with a replace value of "59":

"You are 59 dats from x, please go to [link] to find out more" - Link is broken

It seems if the content around the link is in any way different then the link becomes broken.

Jan 15, 2016 16:47

I've never seen people fetching HTML off a block in that manor (using CacheManager).

If you instead use the defined property you can do ToHtmlString() on it and then the URLs will be rewritten and consistent.

For example:

message = yourBlock.YourXhtmlStringProp.ToHtmlString().Replace(etc..)

Jan 15, 2016 17:09
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.