Asp.net mvc RedirectToAction未传递所有参数

Asp.net mvc RedirectToAction未传递所有参数,asp.net-mvc,asp.net-mvc-2,Asp.net Mvc,Asp.net Mvc 2,我在同一个控制器中有这两种方法,第一种方法将两个参数传递给第二种方法 调试时,传递的列表(model.RequestedProducts)是正确的(不是空的),但在第二种方法中,只有idOR被正确读取,list RequestedProducts是空的 [HttpPost] public ActionResult Index(int idOR, ViewModel model, string add, string remove, string send) {

我在同一个控制器中有这两种方法,第一种方法将两个参数传递给第二种方法

调试时,传递的列表(
model.RequestedProducts
)是正确的(不是空的),但在第二种方法中,只有idOR被正确读取,
list RequestedProducts
是空的

    [HttpPost]
    public ActionResult Index(int idOR, ViewModel model, string add, string remove, string send)
    {
        //...
                return RedirectToAction("Done", 
                                         new { idOR = idOR, 
                                         RequestedProducts = model.RequestedProducts});       
    }

    public ActionResult Done(int IdOR, List<OCS> RequestedProducts)
    { ...
[HttpPost]
公共ActionResult索引(int-idOR、ViewModel模型、字符串添加、字符串删除、字符串发送)
{
//...
返回重定向到操作(“完成”,
新的{idOR=idOR,
RequestedProducts=model.RequestedProducts});
}
公共行动结果完成(int IdOR,列出请求的产品)
{ ...
我错过了什么

有没有更好的方法?(除了重定向到操作之外)


谢谢

当您使用
重定向到操作
时,您正在向客户端返回一条消息,请求一个新的URL,可能类似于
/controller/action/id
。您的
路由
将定义URL的形成方式。我猜您已经定义了默认路由,而在您的情况下,MVC无法知道如何获得该URL将RequestedProducts类型alise为URL,然后将其绑定回列表类型

相反,您可以使用对象在操作请求之间传递数据

TempData属性值存储在会话状态中。设置TempDataDictionary值后调用的任何操作方法都可以从对象中获取值,然后处理或显示这些值。TempData的值会一直保持,直到读取或会话超时为止


解释这一切。

谢谢你花时间回答我的问题。它用TwitDATA工作得很好。你认为哪种更具诱惑力,改变<代码>路由< /代码>或使用TwitDATA?只需意识到使用TestDATA将使用会话。