asp.net mvc3 return raw html to view

后端 未结 7 685
时光说笑
时光说笑 2020-12-13 08:01

Are there other ways I can return raw html from controller? As opposed to just using viewbag. like below:

public class HomeController : Controller
{
    publ         


        
7条回答
  •  粉色の甜心
    2020-12-13 08:36

    That looks fine, unless you want to pass it as Model string

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            string model = "";
            return View(model);
        }
    }
    
    @model string
    @{
        ViewBag.Title = "Index";
    }
    
    @Html.Raw(Model)
    

提交回复
热议问题