Try our conversational search powered by Generative AI!

UnFriendly URL from XHTML-property

Vote:
 

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; http://wwwtest.company.se/link/1789998ab7954e2e9ad8f6120b348982.aspx?id=16054&epslanguage=sv).

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?

#77199
Nov 12, 2013 20:24
Vote:
 

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

 

cheers!

#77200
Nov 12, 2013 20:40
Vote:
 

Neary true Marcus,  I have a helperfunction 

@helper NavigationItemTemplate(string header, XhtmlString content) {

    <div>

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

    {   

        <h3>@header</h3>

        @content

    }

    </div>

}

 

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

#77203
Nov 12, 2013 21:02
Vote:
 

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

#77210
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.