[ValidateAntiForgeryToken] // used to prevent CSRF attacks. Used in conjuction with @Html.AntiForgeryToken() on view, this validates this token existed on the form that submitted this request. public ActionResult Create(GigFormViewModel viewModel) { if (!ModelState.IsValid) { viewModel.Genres = Context.Genres.ToList(); return(View("GigForm", viewModel)); // will return current model back to same view, which will keep fields populated and validation messages displayed } Gig gig = new Gig { ArtistId = User.Identity.GetUserId(), DateAdded = viewModel.GetDateAdded(), GenreId = viewModel.Genre, Venue = viewModel.Venue }; gig.Create(); Context.Gigs.Add(gig); Context.SaveChanges(); // writes to the database return(RedirectToAction("Mine", "Gigs")); }