我的控制器是:
public ActionResult Action1(Action1Model model)
{
.....
if (...)
return Action2(new Action2Model() { .... } ); //**
else
return View(model);
}
public ActionResult Action2(Action2Model model)
{ ... }
基本上,在 Action1 的某些条件下,我想将处理转移到 Action2。上面的代码给了我一个错误:The model item passed into the dictionary is of type 'Action2Model', but this dictionary requires a model item of type 'Action1Model'
.
我可以通过在 ** 行使用它来使其工作:
return RedirectToAction("Action2", new { parm1 = ..., parm2 = ... ...});
但是这种方法返回一个 302(额外的 Http 调用),暴露了查询字符串上的所有参数,不能有复杂的模型,并且在填充路由值时没有类型检查。
有没有一种很好的方法来传输操作而不在查询字符串上暴露模型详细信息?