views:

500

answers:

2

When using ActionLink to render data from database which has HTML tags

(ie <p>)

incorporated in it, ActionLink escapes the tags. What is the best way to handle this?

+1  A: 

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

If you just want to render some HTML from the database, you can use <%= ViewData["MyContent"] %> if you're controller loads the data into the MyContent view data. Just know that you have to clean this HTML yourself.

Lance Fisher
+1  A: 

In valid (X)HTML, paragraph tags are disallowed inside of anchor tags, so I wouldn't expect the framework to allow it.

John Sheehan
actually, you are right, this is where my problem is. Would i need to remove all html before passing string to Actionlink?
zsharp
That's what I would do
John Sheehan