What does HTML.Raw do?

后端 未结 4 1692
有刺的猬
有刺的猬 2020-12-06 17:09

Is HTML.raw() specific to MVC? On what scenarios we have to use it?

Can you please explain with an example.

4条回答
  •  被撕碎了的回忆
    2020-12-06 17:53

    Html.Raw

    • Wraps HTML markup in an HtmlString instance so that it is interpreted as HTML markup.

    For Example :

    Controller

    public actionresult Htmlraw()
    {
    viewbag.message = "Hey friends lets go" + "
    " + "for chillout"; return view(); }

    index view

    @Html.Raw(ViewBag.message);
    

    output

    hey friends lets go

    for chillout

提交回复
热议问题