Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ValidateModel(viewModel);
- TryValidateModel(viewModel)
- [HttpGet]
- public ActionResult Index()
- {
- var viewModel = new RandomVieModel();
- ValidateModel(viewModel); //For example
- return View(viewModel);
- }
- [HttpPost]
- public ActionResult Index(RandomViewModel viewModel)
- {
- if(!ModelState.IsValid)
- {
- return View(viewModel);
- }
- return RedirectToAction("SomethingNew);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement