Here is the problem,
i have one controller:
[AcceptVerbs(开发者_JAVA技巧HttpVerbs.Post)]
public ActionResult Detail(SomeObjectX a)
{
SomeObjectY b = new SomeObjectY();
b.merge(a); //i already have merge method.
return RedirectToAction("SomeAction", "SomeController", new { c = b });
}
is it possible to pass object b to other action on different controller, in this case, to SomeAction on SomeController. thanks for your help :)
In your first action, Detail,
TempData["some-key-here"] = b;
In the action you want to receive the object, SomeAction
SomeObjectY b = (SomeObjectY)TempData["some-key-here"];
Edit: you don't need the parameters in the RedirectToAction this way.
Here's a way to pass objects on redirect without using any magic strings: http://jonkruger.com/blog/2009/04/06/aspnet-mvc-pass-parameters-when-redirecting-from-one-action-to-another/
精彩评论