在一个ASP.NET应用中,我使用下面的代码从共享路径读取视频文件并在浏览器中播放。对于小于300 MB的文件,它可以工作正常,但是对于650 MB及以上的文件会抛出内存不足的异常,并且对于大于2 GB的文件会抛出如下限制错误:
我的代码:文件过长。此操作目前仅支持小于2 GB的文件。
ImpersonationHelper.Impersonate(ConfigurationManager.AppSettings["Domain"], ConfigurationManager.AppSettings["UserName"],ConfigurationManager.AppSettings["Password"], delegate
{
FileBuffer = System.IO.File.ReadAllBytes(filepath);
if (FileBuffer != null)
{
Response.Buffer = true;
Response.ContentType = contenttype;
Response.AddHeader("Content-Disposition", "inline");
Response.AddHeader("content-length", FileBuffer.Length.ToString());
Response.BinaryWrite(FileBuffer);
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.Close();
Response.End();
}
});