为什么上传文件到ASP。NET web应用程序大于12MB显示为0MB?

时间:2022-02-02 06:34:01

Our ASP.NET C# web application is used in the following environment - .NET Framework 4 - IIS 7 - Windows 2008 - Visual Studio 2010 .NET IDE - C# - HTTPS ( SSL ) Our ASP.NET C# web application uploads various files like jpgs, mp4, mp3, pngs, docx, txt, etc to a folder called ClientBin. However, if we deploy the application to an IIS7 server, we have to give the web user of our application permission to upload file. We give the \IIS_IUSRS group permission to execute, read, write and execute on our ClientBin upload folder.

我们的ASP。NET c# web应用程序在以下环境中使用-。NET框架4 - IIS 7 - Windows 2008 - Visual Studio 2010。NET - c# - HTTPS (SSL)我们的ASP。NET c# web应用程序上传各种文件,如jpg、mp4、mp3、pngs、docx、txt等文件到一个名为ClientBin的文件夹。但是,如果我们将应用程序部署到IIS7服务器上,我们必须给应用程序的web用户上传文件的权限。我们给予IIS_IUSRS组权限来执行、读取、写入和执行我们的ClientBin上传文件夹。

A web user can upload files that have size less than approximately 12MB.

web用户可以上传大小小于12MB的文件。

However, when a web user uploads any more than approximately 12MB, the file that gets uploaded will be 0 bytes on the server's ClientBin upload folder.

但是,当web用户上传的文件超过12MB时,上传的文件将在服务器的ClientBin上传文件夹中为0字节。

In our Web.config, we have the following configurations for httpRuntime tag:

在我们的网站。配置,我们对httpRuntime标记有以下配置:

<system.web>
  ...
  .....
  ........
  ..............
  <httpRuntime maxRequestLength="1048576" executionTimeout="50000"
       useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="15360"
       minFreeThreads="8" minLocalRequestFreeThreads="4"
       appRequestQueueLimit="100" />
</system.web>

In our Web.config, we have the following configurations for requestLimits tag:

在我们的网站。配置,我们对requestlimit标签有以下配置:

<system.webServer>
  ..............
  .........................
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="2000000000" />
      <fileExtensions>
        <add fileExtension=".aspx" allowed="true" />
      </fileExtensions>
    </requestFiltering>
  </security>
</system.webServer>

I also took the undesired approach of modifying the machine.config file by creating the following settings:

我还采用了不希望的方法来修改机器。通过创建以下设置配置文件:

<system.web>
  <processModel responseDeadlockInterval="0:09:00"
                                  responseRestartDeadlockInterval="0:09:00" />
  .....................
  ..........................................
  .............................................................
</system.web>

I also took the following steps: I checked Event Viewer and IIS Logs but it failed to show strange.

我还执行了以下步骤:我检查了事件查看器和IIS日志,但它没有显示奇怪的日志。

Files that have a size of anything less than approximately 12 MB gets uploaded properly.

大小小于12 MB的文件会被正确地上传。

It is important to note that the files do get uploaded, but it all ends up 0Kb. The file name and type that gets uploaded is the same as the one on my desktop but the size is 0Kb. The one on my desktop is approximately 75MB.

需要注意的是,这些文件确实被上传了,但最终都是0Kb。上传的文件名和类型与我桌面上的文件名和类型相同,但是大小是0Kb。我桌面上的这个大约是75MB。

ASP.NET and IIS don't throw any error pages.

ASP。NET和IIS不会抛出任何错误页面。

Why are uploaded files to ASP.NET web Application greater than 12MB being shown as 0MB ?

为什么上传文件到ASP。NET web应用程序大于12MB显示为0MB ?

1 个解决方案

#1


3  

Try increasing requestLengthDiskThreshold to match maxRequestLength

尝试增加requestLengthDiskThreshold以匹配maxRequestLength。

<configuration>
    <system.web>
        <!-- maxRequestLength and requestLengthDiskThreshold is in Kilobytes-->
        <httpRuntime maxRequestLength="204800" requestLengthDiskThreshold="204800" />
    </system.web>
    <system.webServer>
        <security>
            <requestFiltering>
                <!-- maxAllowedContentLength is in Bytes not Kilobytes -->
                <requestLimits maxAllowedContentLength="204800000" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>

Also, have you tried using a more comprehensive ASP.NET upload control such as the Telerik RadUpload module? It's available as a free trial to see if it will solve your issues.

此外,您是否尝试过使用更全面的ASP。NET上传控件,比如Telerik RadUpload模块?它可以作为免费试用,看看它是否能解决你的问题。

#1


3  

Try increasing requestLengthDiskThreshold to match maxRequestLength

尝试增加requestLengthDiskThreshold以匹配maxRequestLength。

<configuration>
    <system.web>
        <!-- maxRequestLength and requestLengthDiskThreshold is in Kilobytes-->
        <httpRuntime maxRequestLength="204800" requestLengthDiskThreshold="204800" />
    </system.web>
    <system.webServer>
        <security>
            <requestFiltering>
                <!-- maxAllowedContentLength is in Bytes not Kilobytes -->
                <requestLimits maxAllowedContentLength="204800000" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>

Also, have you tried using a more comprehensive ASP.NET upload control such as the Telerik RadUpload module? It's available as a free trial to see if it will solve your issues.

此外,您是否尝试过使用更全面的ASP。NET上传控件,比如Telerik RadUpload模块?它可以作为免费试用,看看它是否能解决你的问题。