ASP.net CSV file upload
When I want to try the file upload in ASP.Net MVC,I am receive the
following error.
file errorA first chance exception of type 'System.NullReferenceException'
occurred in administratorPortal.dll file errorThe thread '' (0x21e4) has
exited with code 0 (0x0). A first chance exception of type
'System.NullReferenceException' occurred in administratorPortal.dll
in my view
<form action="../../Controllers/patientAppointmentController.cs" method=post>
<input id="model" type="file" name="fileUpload" data-val="true"
data-val-required="File is required" />
<input class="btn btn-primary" type="submit" value="Import" />
</form>
in my controller
public ActionResult CSVUpload(HttpPostedFileBase fileUpload)
{
try
{
Debug.Write(fileUpload.ContentLength);
if (fileUpload.ContentLength < 0 || fileUpload == null)
{
Debug.Write("unable to detectFile");
}
}
catch
{
Debug.Write("file error");
}
return View();
}
there is some problem, i cant even get the file passed to the controller.
i had tried many different method found on the internet, but none of them
work for me.
i had install CSVhelper
thanks so much for helping !
weiyang
No comments:
Post a Comment