web.config中的maxRequestLength导致内部错误。

4
我想允许我的用户上传大文件,因此我将web.config更改为以下内容:
     <configuration>
     <configSections>
      <sectionGroup name="applicationSettings"    type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0,    Culture=neutral, PublicKeyToken=" >
        <section name="delegatezanjan.Properties.Settings"    type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0,   Culture=neutral, PublicKeyToken=" requirePermission="false" />
      </sectionGroup>
    </configSections>
        <system.web>
      <compilation debug="true" targetFramework="4.0">
         <assemblies>
          <add assembly="System.Design, Version=4.0.0.0, Culture=neutral,   PublicKeyToken="/>
        </assemblies>
        </compilation>
       <httpRuntime/>
  <httpRuntime maxRequestLength="200000" executionTimeout="99999"/>
    </system.web>
    <system.serviceModel>
      <bindings>
        <basicHttpBinding>
        <binding name="smsSendWebServiceSoap" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://aryanmsg.ir/smsSendWebService.asmx"
        binding="basicHttpBinding" bindingConfiguration="smsSendWebServiceSoap"
        contract="ServiceReference1.smsSendWebServiceSoap" name="smsSendWebServiceSoap" />
    </client>
     </system.serviceModel>
    <applicationSettings>
    <delegatezanjan.Properties.Settings>
      <setting name="delegatezanjan_ir_smsline_webservice_SMS_WebServer_Service"
        serializeAs="String">
        <value></value>
      </setting>
    </delegatezanjan.Properties.Settings>
     </applicationSettings>
     <system.webServer>
      <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483648" />
        </requestFiltering>
      </security>
    </system.webServer>
</configuration>

在添加这部分代码之前,我的代码可以正常工作。但是在添加了最后三行后,我的网站返回了500内部服务器错误:

您正在查找的资源存在问题,无法显示。


2TB?认真的吗?私下里,我想你可能是个疯子 :-) 无论如何,你已经有了一个在顶部附近的system.web部分。你确定它不应该在那里吗? - paxdiablo
正如pax所说,您已经在配置文件中先前声明了system.web。尝试将其移动到那里。并尝试减少requestlength和execution timeout,这些值完全疯狂。maxRequestLength的最大限制为2GB。关于executionTimeout不太确定。哦,刚看到你的回答Selva,抱歉! - BobbyDazzler
@MightyLampshade,我已经更改了它,但是仍然出现相同的错误。 - SSC
1
你在配置文件中声明了两次httpRuntime。你有<httpRuntime /><httpRuntime maxRequestLength="2000000000" executionTimeout="99999999"/> - BobbyDazzler
你可以将帖子作为答案发布。 - SSC
显示剩余2条评论
3个回答

23

将其作为答案 :)

在您的配置中声明了 httpRuntime 两次。您有

<httpRuntime /> 

以及

<httpRuntime maxRequestLength="2000000000" executionTimeout="99999999"/>

4

maxRequestLength 的最大限制为 2 GB (2147483648),maxAllowedContentLength 的最大限制为 4 GB (4294967295)。如果要上传超大文件,则可以使用一些第三方工具,例如 Ultimate uploader 来上传。


3
数值 2147483648 根据 int 数据类型是无效的。不是有效的 int32。最大值为:2147483647。 - Dainius Kreivys

1

很多时候通过添加行

 <httpRuntime maxRequestLength="214748364" executionTimeout="9999" targetFramework="4.5"/>

返回500错误

请查找您的Web配置文件中已经存在的<httpRuntime />


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接