Okay, so maybe this is a no no in the MVC pattern in which case, that’s the answer I’m looking for. However, let’s say I have some content html in a database and I want to pass it through to the view. I am assuming I could use a ViewData property to pass this through to the page. What sort of massaging do I need to do to the string to get something like <h1>Hello World</h1> to show up as ‘Hello World‘ instead of ‘<h1>Hello World</h1>’.
Okay, so maybe this is a no no in the MVC pattern in which
Share
Nothing, just do
<%=ViewData["yourkey"] %>instead of<%=Html.Encode(ViewData["yourkey"]) %>in your view.Note: Only do this if you are absolutely sure you trust the data in the database!