Original html code:
Background Code:
Then, my viewbag stores html code, the front page does not parse html, directly escapes html code, surely, it is the foreground or background needs to escape!
Today, I will summarize for myself, about ViewBag assigning Html format values, but the display on the web page is not normal;
For example, ViewBag.Content = "<p>Hello, I'm testing something now.</p>";
Front Desk <div>page@VIewBag.Content</div>
The result is displayed on the page: <p>Hello, I am testing something now</p>., I found it when I edited through Firefox, the source code is, <p> Hello, I am testing something now. </p>
This is obviously not what we want, and it corresponds to the HTML format field saved to the database through the editor, and the correct style cannot be displayed after taking it out.
I searched the Internet to find a solution
<div>@Html.Raw(ViewBag.Content)</div>
This is the display normal
|