返回PartialViewResult的动作,必须返回字符串(HTML CODE)

时间:2013-08-07 08:22:31

标签: c# asp.net asp.net-mvc asp.net-mvc-3

初​​始:

public ActionViewResult Action_ASDA(Model model)
{
...
...
return PartialView("My_Model_View",model);
}

好的..现在我需要这个函数来返回HTML代码(功能相同,但我需要以字符串形式返回HTML)

public string Action_ASDA(Model model)
{
...
...
// HTML RESPONSE
Response.Clear();
Action_ASDA(model).ExecuteResult(ControllerContext);
Action_ASDA(model).ExecuteResult(ControllerContext);
return Response.ToString().Replace("System.Web.HttpResponseWrapper", string.Empty);

}

show show“...”是模型生成和完成的代码。

1 个答案:

答案 0 :(得分:0)

如果要返回HTML字符串,可以使用:

string html = "<div>Hello, this is div</div>";
return Content(html, "text/xml");
相关问题