相关疑难解决方法(0)

返回大文件大1 GB时,算术运算中的ASP.NET溢出或下溢

我在ASP.NET中遇到了某种限制.我将问题缩减为ASP.NET MVC项目(使用Visual Studio 2010和.NET 4创建)中的示例项目,问题仍然存在:

在MVC控制器中,我有一个提供文件下载的方法:

public ActionResult DownloadBigFile()
{
    string file = @"C:\Temp\File.txt";
    var readStream = new FileStream(file, FileMode.Open, FileAccess.Read);
    return File(readStream, "text/plain", "FILE");
}
Run Code Online (Sandbox Code Playgroud)

当文件低于1 GB时,下载工作正常,超过1 GB时会抛出异常:"算术运算中出现溢出或下溢",其中包含以下详细信息:

 Overflow or underflow in the arithmetic operation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArithmeticException: Overflow or underflow in the arithmetic operation.

Source Error:

An …
Run Code Online (Sandbox Code Playgroud)

asp.net arithmeticexception

15
推荐指数
1
解决办法
8334
查看次数

标签 统计

arithmeticexception ×1

asp.net ×1