.net 上传大文件失败,大小限制配置问题

本文介绍了如何通过修改.NET应用程序的webconfig文件,调整maxRequestLength和executionTimeout设置,以允许上传大文件并解决大小限制问题。通过增加这两个参数的值,可以确保大文件上传不会因请求长度或执行超时而失败。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

webconfig文件配置修改:

修改maxRequestLength和executionTimeout这2个信息

<httpRuntime executionTimeout="3600" maxRequestLength="2147483647" useFullyQualifiedRedirectUrl="false" requestValidationMode="2.0" />

 

webconfig文件最后添加如下节点:

 <security>
      <requestFiltering>
        <!--修改服务器允许最大长度 300M-->
        <requestLimits maxAllowedContentLength="2147483647"/>
      </requestFiltering>
    </security>

修改上面即可。

    <sessionState mode="InProc" />
    <!--<sessionState mode="InProc" timeout="30" />-->
    <pages validateRequest="false" enableEventValidation="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
      <controls>
        <add tagPrefix="anthem" namespace="Anthem" assembly="Anthem" />
        <add tagPrefix="webdiyer" namespace="Wuqi.Webdiyer" assembly="AspNetPager" />
      </controls>
    </pages>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="utf-8" />
    <httpRuntime executionTimeout="3600" maxRequestLength="2147483647" useFullyQualifiedRedirectUrl="false" requestValidationMode="2.0" />
    <authentication mode="Windows" />
    <!--
            如果在执行请求的过程中出现未处理的错误,
            则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
            开发人员通过该节可以配置
            要显示的 html 错误页
            以代替错误堆栈跟踪。
    -->
    <customErrors mode="Off" defaultRedirect="404.htm">
    </customErrors>
  </system.web>
  <system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.aspx" />
        <add value="forumindex.aspx" />
        <add value="spaceindex.aspx" />
        <add value="albumindex.aspx" />
      </files>
    </defaultDocument>
    <directoryBrowse enabled="true" />
     <security>
      <requestFiltering>
        <!--修改服务器允许最大长度 300M-->
        <requestLimits maxAllowedContentLength="2147483647"/>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值