public ActionResult Index(HttpPostedFileBase file) { // Verify that the user selected a file if (file != null && file.ContentLength > 0) { //if (verficarExcel(file.FileName)) //{ // extract only the fielname var fileName = Path.GetFileName(file.FileName); ExcelImport excelImport = new ExcelImport(); // store the file inside ~/App_Data/uploads folder string strExtension = Path.GetExtension(fileName); string strUploadFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + strExtension; var path = Path.Combine(Server.MapPath("~/UploadFiles"), strUploadFileName); file.SaveAs(path); String resul = Convert.ToString(excelImport.importToSQL(strExcelConn(path, strUploadFileName))); //} } // redirect back to the index action to show the form once again return RedirectToAction("Index", "Establecimientos"); }