public ActionResult Index(ProductModel model) { if (ModelState.IsValid) { try { // process request.. // set flag model.IsTransactionCompleted = true; // save model state ProductModel = model; return RedirectToAction("Index"); } catch (InvalidOperationException ex) { // add any other errors as global errors.. ModelState.AddModelError(String.Empty, ex.Message); } } return View(model); }
public ActionResult Index() { // retrieve model state if redirected ProductModel model = ProductModel; if (model == null) { model = new ProductModel { ProductId = 123456, ProductName = "Wine", PurchaseQuantity = 1, }; } return View(model); }