RedirectToAction with parameter

后端 未结 14 1898
傲寒
傲寒 2020-11-22 08:56

I have an action I call from an anchor thusly, Site/Controller/Action/ID where ID is an int.

Later on I need to redirect to th

14条回答
  •  被撕碎了的回忆
    2020-11-22 09:39

    If your parameter happens to be a complex object, this solves the problem. The key is the RouteValueDictionary constructor.

    return RedirectToAction("Action", new RouteValueDictionary(Model))
    

    If you happen to have collections, it makes it a bit trickier, but this other answer covers this very nicely.

提交回复
热议问题