Try our conversational search powered by Generative AI!

UnFriendly URL from XHTML-property


We have some xhtml-property where users add links to other pages on the same site with the built in tiny-MCE editor. The problem we have is that EPiServer is writing out the unfriendly version of the url to the page (for example;

This takes the visitor to first a 301-page and then to the friendly version of the url but with id and language parameters.

Are there any way to get the xhtml-property to write out the friendly version of url?

Nov 12, 2013 20:24

You are most certainly using @Html.Raw(Model.MainBody), instead you should use @Html.PropertyFor(x => Model.MainBody)



Nov 12, 2013 20:40

Neary true Marcus,  I have a helperfunction 

@helper NavigationItemTemplate(string header, XhtmlString content) {


    @if (header != null && content != null)








And when writing @content it does this.
Using ProprtyFor fix this

Nov 12, 2013 21:02

There is another solution to this problem that we find and I write it here so others can use it.

There are places where you can't/don't want to use PropertyFor, for example in the footer of the page or in a more advanced menu. In that case you can use @Html.XhtmlString(content) (Where content is XHTML-string) instead of just @content and that will make EPiServer to write out friendly url instead of unFriendly.

Thanks to Magnus Forsberg at Active Solution who showed me that

Nov 13, 2013 8:05
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.