在asp.net和c#上传文件

时间:2012-02-13 15:16:46

标签: c# asp.net upload

我想知道一些事情。

当我将文件上传到服务器时,当文件大约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>

2 个答案:

答案 0 :(得分:2)

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

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

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

答案 1 :(得分:1)

你为maxRequestLength尝试了-1吗? -1指定没有限制。