C# 多用户正在访问Zip文件-Mem出异常问题

C# 多用户正在访问Zip文件-Mem出异常问题,c#,asp.net-mvc-3,download,C#,Asp.net Mvc 3,Download,这就是我目前所知道的 在我看来 @foreach (var file in item.AssociatedFileList) { @Html.ActionLink(file.FileName, "GetFile", "Landing", new { path = file.FilePath }, new { target = "_blank" }) <br /><br /> } 后来我检查了filestream OIObject的文件大小,它是108

这就是我目前所知道的

在我看来

@foreach (var file in item.AssociatedFileList)
{      
    @Html.ActionLink(file.FileName, "GetFile", "Landing", new { path = file.FilePath }, new { target = "_blank" }) <br /><br />
}
后来我检查了filestream OIObject的文件大小,它是108560843


我把我能想到的一切都放在这个问题上。这是我第一次使用文件,我不想错过任何细节。

禁用页面检查器。如何禁用页面inst从“运行”旁边的下拉列表中取消选中“启用浏览器链接”。哇,现在可以使用了,谢谢。页面检查器对我的代码做了什么,但它不起作用。它试图在内存中缓冲整个文件。
public ActionResult GetFile(string path)
    {
        var extension = Path.GetExtension(path);
        FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);

        if (extension == ".pdf")
            return File(fs, "application/pdf", Path.GetFileNameWithoutExtension(path));

        if (extension == ".xlsx" || extension == ".xls")
            return File(fs, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", Path.GetFileNameWithoutExtension(path));

        if (extension == ".zip")
            return File(fs, "application/zip", Path.GetFileNameWithoutExtension(path));                       

       return this.Content("<html><center><span style='font-size: large; font-weight: bold; font-family: 'Century Gothic', 'PT Sans', 'Verdana', 'Arial', 'Helvetica', 'sans-serif'; color: #FF0000;'>There is no file to view<span></center></html>");
    }
@Html.ActionLink(file.FileName, "GetFile", "Landing", new { path = file.FilePath }, new { target = "_blank" }) <br /><br />
Server Error in '/' Application.

Exception of type 'System.OutOfMemoryException' was thrown.

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.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

Source Error: 

An unhandled exception was generated during the execution of the current web request.    Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
System.IO.MemoryStream.set_Capacity(Int32 value) +93
System.IO.MemoryStream.EnsureCapacity(Int32 value) +64
System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count) +330
Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.ArteryFilter.Write(Byte[]   buffer, Int32 offset, Int32 count) +106
System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr) +9509748
System.Web.HttpResponse.FilterOutput() +104
System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +49
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69