Answer the question
In order to leave comments, you need to log in
Upload 350000 rows to the server, how to do?
There is an ASP.NET MVC site hosted on reg.ru
, there is an Excel file at the input, the contents of the file must be loaded through the site into the database. There is a problem most likely with the connection timeout, "ERR_CONNECTION_RESET" appears - Unable to access the site. The file weighs 8MB, the number of records is 350,000. (It can be more than about 800 thousand).
In Web.config I currently have
<httpRuntime maxRequestLength="16384" executionTimeout="3600"/>
[HttpPost]
public ActionResult UploadLsGis(HttpPostedFileBase upload2)
{
List<LsKvitGis> l = new List<LsKvitGis>();
if (upload2 != null && upload2.ContentLength > 0)
{
int SN = 1;
var fileName = Path.GetFileName(upload2.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/Files"), fileName);
upload2.SaveAs(path);
using (XLWorkbook workBook = new XLWorkbook(path))
{
var ws = workBook.Worksheet(1);
int lastrow = ws.LastCellUsed().Address.RowNumber;
while (SN<=lastrow)
{
l.Add(new LsKvitGis {
LS = ws.Row(SN).Cell(1).Value.ToString(),
LSGis = ws.Row(SN).Cell(2).Value.ToString()
});
SN++;
}
}
db.lsKvitGiss.RemoveRange(from s in db.lsKvitGiss select s); //удаляю что было раньше
db.lsKvitGiss.AddRange(l); // добавляю
db.SaveChanges(); // сохраняю
ViewBag.Message = "Файл с ЛС ГИС загружен";
}
return View("Index");
}
Answer the question
In order to leave comments, you need to log in
You can try to split the file into chunks and send them in stages with different requests.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question