asp.net 如何修复此错误:超过最大请求长度?

kzmpq1sx  于 6个月前  发布在  .NET
关注(0)|答案(2)|浏览(94)

我试图导出一个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 -内部服务器错误。您正在查找的资源有问题,无法显示。

hmae6n7t

hmae6n7t1#

添加这段代码后,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>

字符串

tkclm6bt

tkclm6bt2#

我认为在你的情况下,内部服务器错误正在发生,因为你给maxrequestlength太大的值。
尝试给值-2097151,如果你试图设置更多500发生内部服务器错误.

相关问题