HTMl Helpers in MVC: How to render html tags using a helper like ActionLink?

When using ActionLink to render data from a database with HTML tags

(ie <p>) 

      

included in it, ActionLink accelerates tags. What's the best way to handle this?

+1


source to share


2 answers


In valid (X) HTML, paragraph tags are prohibited inside anchor tags, so I didn't expect the framework to be able to resolve it.



+1


source


I don't know that you can turn off XSS protection in helper methods, but you can always create your own helper methods. Just create an extension method that depends on the Html class.



If you just want to display some HTML from the database, you can use <% = ViewData ["MyContent"]%> if the controller is loading data into the view data of MyContent. Just know that you have to clean up this HTML yourself.

+1


source







All Articles