Return the right parent's `get` after a child `post` action

Viewed 193

I have the same child action placed in several parents actions, let's say there are these two parent views :

@model Parent1Model 

@{
ViewBag.Title = "Parent1";
Layout = "~/Views/Shared/_Layout.cshtml";

}
@Html.Action("Child","MainControler")

The second parent :

@model Parent2Model

@{
ViewBag.Title = "Parent2";
Layout = "~/Views/Shared/_Layout.cshtml";

}
@Html.Action("Child","MainControler")

All actions are placed in the same controller.

public ActionResult parent1() //GET
{
    Parent1Model model = new Parent1Model()
    return View(model );
}
public ActionResult parent2() //GET
{
    Parent2Model model = new Parent2Model()
    return View(model );
}
public ActionResult Child() //GET
{
    ChildModel model = new ChildModel()
    return View(model );
}

[HttpPost]
public ActionResult Child(ChildModel model) //POST
{
    DoThingsWithResult(model)

    // The next line should return the get of the parent action

    return RedirectToParent() // This does not exist...
}

Now, how do i tell the child to call his RIGHT parent's GET? Being the child of many parents, how can he know which parent called it this time ?

I could not find anything, neither on google nor in the "Questions that may already have your answer".

1 Answers
Related