1、使用@Html.Raw(str)
@Html.Raw("<div style='color:red'>输出字符串</div>")
2、使用new HtmlString
IHtmlString content = new HtmlString("<div style='color:red'>输出字符串</div>");
@content;
3、直接输出带html标签的html
string htmlcode="<div style='color:red'>输出字符串</div>";
@htmlcode;
参考资料:mvc razor模式 输出html http://www.studyofnet.com/news/1171.html