public ActionResult UploadFileFormAction() { var result = ""; var userList = new List <Dictionary <string, string> >(); var uploadedCsvPath = ""; var httpPostedFileBase = Request.Files["csvfile"]; if (httpPostedFileBase != null && httpPostedFileBase.ContentLength > 0) { var fileName = httpPostedFileBase.FileName.Split('\\').Last(); var extension = Path.GetExtension(fileName); var uploadedFilesPath = GlobalAppSettings.GetUploadedFilesPath(); if (Directory.Exists(uploadedFilesPath) == false) { Directory.CreateDirectory(uploadedFilesPath); } if (extension == ".csv") { uploadedCsvPath = String.Format("{0}\\{1}", uploadedFilesPath, fileName); if (System.IO.File.Exists(uploadedCsvPath)) { System.IO.File.Delete(uploadedCsvPath); } httpPostedFileBase.SaveAs(uploadedCsvPath); userList = new UserManagementModel().SaveuserBulkUpload(uploadedCsvPath); result = "Success"; } else { result = "Error"; } } ViewBag.Pathname = uploadedCsvPath; ViewBag.UsersList = Json(new { Data = userList }); ViewBag.UserExists = httpPostedFileBase != null && userList.Count == 0; ViewBag.ser = GlobalAppSettings.Serializer.Serialize(ViewBag.UsersList); ViewBag.UserCount = userList.Count; ViewBag.result = result; return(View()); }