public ActionResult ValidateKey(ValidateKeyModel viewModel) { if (!ModelState.IsValid) return View(viewModel); //custom validation if (viewModel.NewPassword != viewModel.Confirm) { ModelState.AddModelError("PASSAWORD_AND_CONFIRM_DONT_MACHT", ""); } if (viewModel.Key == "123") { ModelState.AddModelError("INVALID_KEY", ""); } //retorn of view if (ModelState.IsValid) { return View("ValidateKeySuccess"); } else { return View(viewModel); } }
public ActionResult ValidateKey() { ValidateKeyModel viewModel = new ValidateKeyModel(); viewModel.Key = Request["Key"]; return View(viewModel); }