C#Razor语法 - html.displayfor显示为文本,而不是html

shu*_*ath 5 c# asp.net-mvc linq-to-sql razor

我的模特:

    public class htmlDump {
        public string html { get; set; }
    }

    public string getSquares() {
        var sq = (from s in n.squares
                  where s.active == true
                 orderby s.date_created descending
                 select s.html).First();
        return sq;
    }
Run Code Online (Sandbox Code Playgroud)

我的控制器:

    public ActionResult index() {
        intranetGS.htmlDump sq = new intranetGS.htmlDump {
            html = g.getSquares()
        };

        return View(sq);
    }
Run Code Online (Sandbox Code Playgroud)

我的看法:

 @Html.DisplayFor(model => model.html)
Run Code Online (Sandbox Code Playgroud)

我想要的只是传递给视图的html呈现为html而不是文本.当然,我可以在视图中使用不同的东西(而不是.DisplayFor).有什么建议?

非常感谢!

Mik*_*oud 10

@Html.Raw(Model.html)
Run Code Online (Sandbox Code Playgroud)

注意:如果用户可以输入此数据- 请确保已对其进行消毒.