I have implemented a web application using asp.net MVC to convert excel file into .csv file.
Everything is working fine with small file.
But when I am trying to run larger file I was getting the error at client side "ERR_CONNECTION_RESET".
I have done R & D and have found the solution i.e
Even after same I have faced same issue. And then I have implemented threading by referring this Set Timeout For Controller Action.
Now I am getting the exception of "Thread is being aborted".
Here I have added my stack trace. Please help me to sort it out...
Exception: 'Thread was being aborted.' :
StackTrace: 'at System.Data.Common.UnsafeNativeMethods.IRowset.GetData(IntPtr hRow, IntPtr hAccessor, IntPtr pData)
at System.Data.OleDb.OleDbDataReader.GetRowDataFromHandle()
at System.Data.OleDb.OleDbDataReader.GetValueBinding(MetaData info)
at System.Data.OleDb.OleDbDataReader.GetValues(Object[] values)
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at ExcelToCsvConversion.Controllers.HomeController.Check_In_Masters(String sourceFile, String worksheet2, Int32 colNo, String fieldValue)'
Here Is my code....
public ActionResult ConvertToCsv(FileUpload model)
{
var fileName = model.SourceFile;
FileUpload fileUpload = new FileUpload();
try
{
string filename = Path.GetFileName(model.SourceFile);
model.SourceFile = Path.Combine(Server.MapPath("~/App_Data/uploads"), filename);
model.WorkSheet1 = "Upload file$";
System.Threading.Tasks.Task.Factory.StartNew(() => ConvertExcelToCSV_LT(model));
fileUpload.SourceFile = filename;
}
catch (Exception e)
{
ServerExceptionLog(e);
}
return Json(new { filemodel = fileUpload }, JsonRequestBehavior.AllowGet);
}