Reputation: 313
I am developing MVC application where I need to show some html content like image , hyperlink , bold , underline text , etc.
I save this content in SQL server database and fetch it from there.
But when I render it as @Model.Description it shows the text instead of html image or bold text.
But when I manually write such html content in pre tag, it is displayed well and good.
Please advise.
Upvotes: 2
Views: 664
Reputation: 2820
When you just write razor syntax like @Model.SomeProperty
it will automatically encode it. So html will be encoded this way and output will containt > etc... If you want to inject html you should use @Raw(Model.Property)
but you need to be aware that this could inject some malicious js...
Upvotes: 3