I have a RouteLink constructed like so
<p class="articleLink">
@MvcHelper.Html.RouteLink(article.Title, "Article_Route", new RouteValueDictionary() { { "articleId", article.Id }, { "seoUrl", article.SeoUrl } }))
</p>
However, article.Title could potentially contain HTML i.e. the value could be <em>Sample</em> Title which in turn gets rendered like so
<a href="/Article/111111/Sample-Title"><em>Sample</em> Title</a>
Is there any way to prevent the HTML from being escaped, and instead to be treated as actual HTML? Or do I need to create a standard HTML <a href... link in this case (thus losing all the niceties associated with the RouteLink helper).
If you want HTML inside your anchor don’t use the
Html.RouteLink(because it will HTML encode the link text by default as you noticed) instead of build youratag by hand with usingUrl.RouteUrlto generate the url:Or you can create your own non encoding
RouteLinkhelper.