摘要:asp.net mvc 小心Html.RenderAction
在mvc的view上使用Html.RenderAction显示另外一些分布视图时要注意
Html.RenderAction在调用具体action的时候,会和主action的method有关;
主action是get,他也是get,主method是post,他也调post。
简单代码演示
在主action对应的view中,通过Html.RenderAction调用action a。
@{
Html.RenderAction("a");
}
@using(Html.BeginForm())
{
<input type="submit" />
}
仅为演示controller里也很简单
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(FormCollection form)
{
return View();
}
public ActionResult A()
{
return Content("get");
}
[HttpPost]
public ActionResult A(FormCollection form)
{
return Content("post");
}
执行
点按钮post
action a调的是post版的。
人生到處知何似
應似飛鴻踏雪泥

