views:

18

answers:

1

Hello Everybody,

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);        

    }
}

}

+1  A: 

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);
Clicktricity
It doesnt work, debug loop infinitely the HttpPost ActionResult P_Client!
Akawan
Ah ok. Try replacing the line with RedirectToAction("Index")
Clicktricity

related questions