keep viewdata on RedirectToAction

后端 未结 5 1597
深忆病人
深忆病人 2021-02-01 01:40
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult CreateUser([Bind(Exclude = \"Id\")] User user)
{
        ...
        db.SubmitChanges();
        ViewData[\"info\"] = \         


        
5条回答
  •  时光说笑
    2021-02-01 02:33

    If you need this more than once, a nice workaround would be creating ActionFilterAttributes which export/import the tempdata to viewdata and vice-versa. You can pass your ModelState in this way very nicely as well (demonstrated here - #13). With a few adjustments to that piece of code you would have a clean solution, I think.

提交回复
热议问题