Asp.net mvc 带有ModelBind输入参数的asp.net mvc强类型重定向

Asp.net mvc 带有ModelBind输入参数的asp.net mvc强类型重定向,asp.net-mvc,redirect,query-string,strong-typing,Asp.net Mvc,Redirect,Query String,Strong Typing,我的控制器中有一系列动作方法,每个动作方法都有自己的模型作为输入参数绑定 [HttpGet] public MyActionMethod(MyCustomModel data){ ... } ... public class MyCustomModel{ public int total {get;set;} public string description {get;set;} } 现在,如果我尝试调用传递正确的querystring参数集的方法来组合MyCustomM

我的控制器中有一系列动作方法,每个动作方法都有自己的模型作为输入参数绑定

[HttpGet]
public MyActionMethod(MyCustomModel data){
...
}

...

public class MyCustomModel{
    public int total {get;set;}
    public string description {get;set;}
}
现在,如果我尝试调用传递正确的querystring参数集的方法来组合MyCustomModel,那么一切都会按预期工作。 如果我使用以下命令从另一个actionmethod重定向到action方法:

RedirectToAction("MyActionMethod", new { total=10, description="test"});
它也像预期的那样工作

问题是我想实现某种强类型重定向,比如:

RedirectToAction(c => c.MyActionMethod, new MyCustomModel{total=10, description="test"});
使用MvcContrib提供的扩展方法可以实现类似的功能,但不幸的是,由于某些原因,扩展无法在querystring中组成正确的参数集,最终导致错误的请求

有什么想法吗?

你可以

TempData["MyCustomModel"] = new MyCustomModel{total=10, description="test"});
然后

MyCustomModel model = TempData["MyCustomModel"] as MyCustomModel
在重定向到的操作方法中