MVC - Passing Data with RedirectToAction()

前端 未结 8 2115
既然无缘
既然无缘 2020-12-01 15:17

I\'d like to take data entered in an MVC user form and display it in a different view.

The class has the following private variable:

IList

        
8条回答
  •  萌比男神i
    2020-12-01 16:01

    Can't you just make 2 action results with the same name and mark 1 of them with HttpPost?

        public ActionResult UpdateContent(FormCollection preview = null)
        {
            return View(preview);
        }
        [HttpPost]
        public ActionResult UpdateContent(FormCollection collection = null, bool preview = false)
        {
            if (preview)
                return UpdateContent(collection);
            else
                return UpdateContent(null);
        }
    

提交回复
热议问题