PartialView and HTTPPOST action
I've a problem with partial view and controller HTTPPOST action : When I'm in HTTPPOST to my partialview, only partial is return, not index page with partialview.
I don't understand why!
The context :
I've an offer(associated with a viewmodel), composed of 4 parts : Client, SwimmingPool, Cover, Resume I would like make to offer on a single page with partialview, one per parts.
Code in my view (Offer/Index) :
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Index</h2>
<% Html.RenderAction("P_Client"); %>
</asp:Content>
Code in my controller :
public class OfferController : Controller {
public ActionResult Index() {
return View();
}
[HttpGet, ChildActionOnly]
public ActionResult P_Client(string id)
{
blablabla
return PartialView("P_Client", viewmodel);
}
[HttpPost]
public ActionResult P_Client(OfferViewModel ViewModel)
{
return PartialView(ViewModel);
}
}
}
The code in your Post action says
Return PartialView(ViewModel);
so that's what it does - returns a partial view. Change this to
Return View("Index", ViewModel);
链接地址: http://www.djcxy.com/p/42092.html
上一篇: 部分ASP.NET MVC查看提交