在asp.net和c#中上传一个文件

本文关键字:文件 一个 net asp | 更新日期: 2023-09-27 18:24:14

我想知道一些事情。

当我上传一个文件到服务器时,当文件大约25mb时,我可以上传它。当它更多时,看起来响应没有结束,所以它没有上传。。。

这是我的webconfig,在服务器上请求的时间限制是9999秒。。

<authorization>
  <deny users="?" />
  <allow users="*" />
</authorization>
<sessionState cookieless="false"/>
<httpRuntime maxRequestLength="1048576"/>
 </system.web>
  <appSettings>
    <add key="FolderPath"  value="uploads" />
  </appSettings>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
 </configuration>

在asp.net和c#中上传一个文件

如果您在IIS 7.0中托管此内容,您可能还需要使用web.config中的<system.webServer>标记,通过设置maxAllowedContentLength值来增加限制:

<system.webServer>
    <security>
        <requestFiltering>
            <!-- limit to 100MB -->
            <requestLimits maxAllowedContentLength="104857600" />
        </requestFiltering>
    </security>
</system.webServer>

默认值为30000000字节,约为28.6MB

您是否尝试对maxRequestLength使用-1-1指定没有限制。