public object saveprofile(ProfileViewModel profileViewModel) { if (!ModelState.IsValid) { //return RedirectToAction(nameof(Index)); return(View("~/Views/Profile/ProfileView.cshtml", profileViewModel)); } //calling main login check method. if (profileBusiness.saveProfileService(profileViewModel)) { ModelState.Clear(); //showprofile(profileViewModel);//fetch profile data after save ViewBag.SuccessRegister = "Profile has been saved successfully."; } else { ViewBag.ErrorRegister = "Some problem occurred while saving profile data."; } return(View("~/Views/Profile/ProfileView.cshtml", profileViewModel)); }