在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()){ }
仅为演示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版的。
人生无处不陷阱