I want to redirect from an action in one controller to an action in a second controller. Normally I would use RedirectToAction("actionName", "controllerName", objects); The method I want to redirect to has two overloads:
- One for HttpVerbs.Get that is used for direct linking
- One for HttpVerbs.Post accepting reference types that get filled through modelbinding
When I do my redirect with the RedirectToAction method, I get redirected to the GET method by default which off course doesn't match my parameters.
How can I make sure it redirects to the correct action's overload?
--EDIT--
On request some more specific details:
The action I want to redirect to fills the viewData based on the parameters and then calls the correct view.
public ActionResult OverView(SearchBag searchBag, IngredientBag ingredientBag) {
It has a second version for Gets so it can work by GET too:
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult OverView(int colorId, string paintCode, string name, int formulaId) {
return OverView(new SearchBag()
{ ColorId = colorId, PaintCode = paintCode, ColorName = name, FormulaId = formulaId }
, formulaViewData.IngredientBag);
}
The one I'm calling now is in a different controller. It does some pre-calculations, fetches the information needed and then does the exact same thing as the previous actions. I could replicate the code from the first action, but I would rather just call that action.
[AcceptVerbs(HttpVerbs.Post)]
public RedirectToRouteResult ReCalculate(SearchBag searchBag, IngredientBag ingredientBag) {
I could create a temporary local instance of that next controller, but I noticed it doesn't have the correct HTTPContext and doesn't hit Initialization methods.