C# 读取Excel文件抛出FormCollection MVC
我想读取excel文件。我有razor视图C# 读取Excel文件抛出FormCollection MVC,c#,excel,C#,Excel,我想读取excel文件。我有razor视图 @using (Html.BeginForm("ImportData", "Sourced", FormMethod.Post, new { enctype = "multipart/form-data" })) 控制器 public ActionResult ImportData(FormCollection formCollection) HttpPostedFileBase file = Request.Files["UploadFil
@using (Html.BeginForm("ImportData", "Sourced", FormMethod.Post, new { enctype = "multipart/form-data" }))
控制器
public ActionResult ImportData(FormCollection formCollection)
HttpPostedFileBase file = Request.Files["UploadFile"];
byte[] fileBytes = new byte[file.ContentLength];
但是当我有这个文件字节时,它们都是零。我在互联网上阅读了所有的想法,我没有解决方案。你能检查一下你在视图中给出的文件Id并尝试使用它吗。是的,我使用的是同名的文件Id。我有写文件名,但文件字节是空的。你能分享你的.cshtml代码吗文件上载能否请检查您在视图中提供的文件Id并尝试使用它。是的,我正在使用同名的文件Id。我有写入文件名,但文件字节为空。您可以共享文件上载的.cshtml代码吗