如何将模型传递给另一个区域的控制器?

时间:2015-11-06 19:05:07

标签: c# asp.net-mvc controller

我有一个模型,想把它传递给另一个区域的控制器。

这是我的默认操作,但不起作用:

public ActionResult defaultAction()
{
    Class1 myclass = new Class1() { name = "xxx" };

    return RedirectToAction("Index", "MemberHome", 
                             new { area = "member",model=myclass});
}

另一个领域的行动:

[HttpPost]
public ActionResult Index(Class1 c)
{
    return View();
}

1 个答案:

答案 0 :(得分:3)

您正在尝试将// Allow only movement of cells not delete when 'edit' is pressed func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle { return UITableViewCellEditingStyle.None } // Don't indent when there is an edit happening (movement) func tableView(tableView: UITableView, shouldIndentWhileEditingRowAtIndexPath indexPath: NSIndexPath) -> Bool { return false } 类型的复杂对象传递给Class1,这是通过url字符串完成的,因此无法接受。您可以更改要发送的参数,

或使用TempData:

RedirectToAction

然后在你的索引操作中检索它

TempData["class1"] = myclass;