我有以下方法将excel上传到我的ASP.NET MVC应用程序。这在mozilla和chrome中运行良好,但在IE中。
public ActionResult FileUploadForBookCreation(HttpPostedFileBase file)
{
try
{
bool errorvalue = false;
bool duplicateInFile = false;
var lstProductDetails = new List<ProductDetailsForBooksExcel>();
var objProductDetailsvalidation = new ProductDetailsvalidation();
var objproductViewModel = new ProductViewModel();
var lstProductDetailsvalidation = new List<ProductDetailsvalidation>();
string extension = Path.GetExtension(file.FileName);
string validation;
if (extension.Equals(".xls") || extension.Equals(".xlsx"))
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Content/Upload"), fileName);
file.SaveAs(path);
ValidateBookCreationfile(path, false, objProductDetailsvalidation, lstProductDetails, objproductViewModel, lstProductDetailsvalidation);
if (lstProductDetailsvalidation.Any())
{
return Json(lstProductDetailsvalidation);
}
return Json(lstProductDetails);
}
else
{
return Json("Error");
}
}
catch (System.Exception)
{
return Json("Error");
}
}
任何人都知道为什么它只在IE11中发生? :(