Html.Raw is not working asp.net mvc

2019-01-19 10:57发布

问题:

I have some html stored in a table. here is some sample data

<p><span style="font-size: small; color: #ff0000;"><span style="font-size: small;"> <span style="font-size: large; color: #000000;">ਮਾਂ</span><br />  <br />ਚਾਵਾਂ ਸਧਰਾਂ ਦੇ ਨਾਲ ਮਾਏ ਜੋ ਤੂੰ ਬੂਟਾ ਲਾਇਆ,<br />ਦੇ ਮਮਤਾ ਦਾ ਪਾਣੀ ਅੱਜ ਓਹ ਭਰ ਜੋਬਨ ਤੇ ਆਇਆ,<br />

I am trying to display on page, I am using asp.net mvc razor view and using

@Html.Raw(blog.Body)

but its not working. can someone help, what is the reason.

Thanks

Parminder

回答1:

kindly try this:

@Html.Raw(HttpUtility.HtmlDecode(blog.Body));

and let me know if it worked.