【问题标题】:Upload a file in asp.net and c#在asp.net和c#中上传文件
【发布时间】:2012-03-04 23:54:04
【问题描述】:

我想知道一些事情。

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

【问题讨论】:

    标签: c# asp.net upload


    【解决方案1】:

    如果您在 IIS 7.0 中托管它,您可能还需要使用 web.config 中的 &lt;system.webServer&gt; 标记通过设置 maxAllowedContentLength 值来增加限制:

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

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

    【讨论】:

      【解决方案2】:

      您是否尝试将 -1 用于 maxRequestLength。 -1 表示没有限制。

      【讨论】:

      • 将maxRequestLength设置为无限制,会进行Denail攻击,用户可以发布大量数据,并且会给服务器造成负载。您可以将 MaxrequestLength 设置为一些有限的字节数。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-25
      • 2011-03-30
      • 1970-01-01
      • 2011-02-03
      • 2012-08-21
      相关资源
      最近更新 更多