asp.net mvc - The correct way of showing data as HTML -



asp.net mvc - The correct way of showing data as HTML -

i've used asp.net mvc5 in project. want show info recorded in database part of html page. simplest info in database recorded, have <div>this div.</div>

and in cshtml file have

<div> @html.displayfor(m => m.description) </div>

but info not show html tag.

how can explain browser info must interpreted html tag?

use @html.raw instead of @html.displayfor.

most of html helper functions in razor automatically encode values help prevent cross-site scripting attacks. if you're going render raw html user's browser hope you've sanitized prevent attacks.

html asp.net-mvc razor asp.net-mvc-5

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -