如何在ASP.NET MVC中上传文件大小为1.25GB的文件

Pan*_*kaj 5 c# asp.net

我的客户通过应用程序上传的文件超过1 GB。我知道我只能使用asp.net MVC应用程序上传100mb。

 public static byte[] ReadStream(Stream st)
     {
         st.Position = 0;
         byte[] data = new byte[st.Length];
         .
         .
         .        
         . 
}
Run Code Online (Sandbox Code Playgroud)

我收到错误消息是byte[] data = new byte[st.Length];因为 st.Length=1330768612 错误-“引发了'System.OutOfMemoryException'类型的异常。”

有什么办法可以上传超过1GB的文件?为什么我们可以在webconfig中定义maxRequestLength = 0-2097151,

Dal*_*Dal 0

我记得在一个较旧的项目中,我们必须找到一种方法来允许用户为我们的 ASP.NET Web 应用程序上传 2-4GB 文件。

如果我没记错的话,我们使用了“文件上传控件”并编辑了 web.config 以允许更大的文件大小:

<system.web>
     <httpRuntime executionTimeout="2400" maxRequestLength="40960" />
</system.web>
Run Code Online (Sandbox Code Playgroud)

另一种选择是使用 HttpModule:

http://dotnetslackers.com/Community/blogs/haissam/archive/2008/09/12/upload-large-files-in-asp-net-using-httpmodule.aspx