I\'m trying to pass an object from one controller action to another. The object that I\'m passing around looks more or less like this:
public class Person
{
For everyone, that really needs to call some action and return view from another controller with complex object and don't want (or can't) to pass object in TempData
. I use in my app very ugly but working solution:
protected ActionResult InternalRedirectToAction(string action, string controller, object model)
{
var htmlHelper = new HtmlHelper(new ViewContext(
ControllerContext,
new WebFormView(ControllerContext, "HACK"),
new ViewDataDictionary(),
TempData, //for sharing TempData between Actions
new StringWriter()),
new ViewPage());
var otherViewHtml = htmlHelper.Action(action, controller, model);
return Content(otherViewHtml.ToString());
}
Inspired by answer found here: https://stackoverflow.com/a/4360019/1341409