ASP.NET MVC顯示HTML字符串

Controller 後臺

截圖:

代碼:

  public ActionResult myhome()
        {
            ViewBag.Message = "<div style='color:red;'>關注我瞭解更多</div>";
            return View();
        }

myhome.cshtml 頁面

截圖:

代碼:

<div class="container">
    導入失敗,請嚴格按照模板格式!!!<br />
    錯誤原因:
    @Html.Raw(HttpUtility.HtmlDecode(ViewBag.Message))
</div>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章