【问题标题】:How to fix this error:Maximum request length exceeded?如何解决此错误:超出最大请求长度?
【发布时间】:2017-12-26 10:21:45
【问题描述】:

我正在尝试将 GridView 导出到 Excel 文件,该文件来自 Access 数据库,因此当我将此内容放入 web.config 文件时。网站在asp.net,后端代码为vb。

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

<system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>

我收到服务器错误

500 - 内部服务器错误。 您要查找的资源有问题,无法显示。

【问题讨论】:

  • 那么这个问题到底是关于什么的?您在问题标题中关于“超出最大请求长度”的错误或您在详细信息中列出的错误 500?究竟什么时候发生错误?此外,excel 和 ms-access 与这些错误有什么关系?除非在您尝试对软件的这些组件执行特定操作时发生错误,否则程序的总体目的可能不相关。在您添加这些特定设置之前,代码是否有效?
  • @C Perkins 所以基本上它就像我需要输入的开始结束时间戳,以便从 MS 访问中查询和检索数据,每当我输入较长的持续时间时,数据必须存储在 Excel 文件中抛出超过最大请求长度,当我在 web.config 文件中进行更改时,我得到 500-Internal server 错误。

标签: asp.net xml excel vb.net ms-access


【解决方案1】:

添加这段代码后,Web.config 中的错误消失了

<configuration>
        <system.web>
          <compilation debug="true" strict="false" explicit="true" targetFramework="4.5.2" />
          <customErrors mode="Off"/>
          <authentication mode="None"/>
          <httpRuntime targetFramework="4.5.2" maxRequestLength="1048576" executionTimeout="3600" />
          <machineKey
    validationKey="929DF4BCF13739428C8C765842BD122C653C28F688D399F216942E5438AA880B4A793C0772A51660FDA9A69B079AB3B0ADFCFC14941F5BBD673BC72E9804DF44"
    decryptionKey="0B4443E8C132884733E8B26587FFCE50562CF8CF9980BAD4813A95D54A7A369B"
    validation="SHA1" decryption="AES"
    />
        </system.web>

      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>

      <appSettings>
        <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
      </appSettings>
</configuration>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-20
    相关资源
    最近更新 更多