我试图在asp.net页面下载大于50mb大小的文件。但它在我们的生产服务器上失败。它适用于开发和QA服务器。我使用下面的代码。asp.net大文件下载内存不足异常
Response.Clear()
oBinaryReader = New System.IO.BinaryReader(System.IO.File.OpenRead(sDocPath))
lFileSize = Microsoft.VisualBasic.FileLen(sDocPath)
Response.AddHeader("Content-Disposition", "attachment;filename=" & sDownloadFileName)
Response.ContentType = "application/unknown"
Response.BinaryWrite(oBinaryReader.ReadBytes(lFileSize))
Response.Flush()
HttpContext.Current.ApplicationInstance.CompleteRequest()
Response.End()
我从服务器收到的错误如下。
Page_Load System.OutOfMemoryException:抛出类型'System.OutOfMemoryException
'的例外。 在在C System.IO.BinaryReader.ReadBytes(的Int32计数) 在ExportDoc.Page_Load(对象发件人,EventArgs的):\网站名称\ ExportDoc.aspx.vb:行87服务器名称
什么是错的码?
您没有正确处理您的[IDiposable](https://msdn.microsoft.com/en-us/library/system.idisposable(v = vs.110).aspx)对象。 – mason