[ValidateAntiForgeryToken] //To prevent cross-site request forgery public async Task <IActionResult> Create(Lecture lecture) { if (!ModelState.IsValid) { var viewModel = new LectureFormViewModel { lecture = lecture }; return(View(viewModel)); } await _serviceLecture.InsertAsync(lecture); return(RedirectToAction(nameof(Index))); }