It is necessary to transfer the entered data between representations. I write them into the session and pass to another view, but at the output I get only the data type (Models.Order). But at the same time in the database data is recorded.
[HttpPost] public ActionResult Index(Order order) { Session["ord"] = order; return RedirectToAction("OrderConfirm"); } public ActionResult OrderConfirm(Order order) { ViewBag.Message = Session["ord"]; return View(); } [HttpPost] public ActionResult OrderConfirm(Order order, string action) { var orders = Session["ord"]; if (action == "Добавить") { db.Entry(orders).State = EntityState.Added; db.SaveChanges(); return RedirectToAction("Index"); } return View(); } @using (Html.BeginForm()) { <p>Подробности заказа: </p> @ViewBag.Message <br /> <input type="submit" name="action" value="Добавить" /> <input type="submit" name="action" value="Отмена" /> } UPD. Made with sessions
[HttpPost] public ActionResult Index(string name, int amount, decimal sum) { Order order = new Order(); order.Name = name; order.Amount = amount; order.Sum = sum; Session["ord"] = order; return RedirectToAction("OrderConfirm"); } public ActionResult OrderConfirm() { Order order = Session["ord"] as Order; if (order != null) { ViewBag.Name = order.Name; ViewBag.Amount = order.Amount; ViewBag.Sum = order.Sum; } return View(); } [HttpPost] public ActionResult OrderConfirm(Order order, string action) { var orders = Session["ord"]; if (action == "Добавить") { db.Entry(orders).State = EntityState.Added; db.SaveChanges(); return RedirectToAction("Index"); } return View(); }