我收到ASP.Net网站关于使用AJAX提交2GB大文件的错误请求。
我的HTTP运行时设置
<httpRuntime maxRequestLength="2147483647" executionTimeout="3600"/>
请帮忙。
的Web.Config
`
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="" providerName="System.Data.SqlClient"/>
<add name="psDevDataConnectionString1" connectionString="" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000" />
</webServices>
</scripting>
</system.web.extensions>
<system.web>
<authentication mode="Forms"/>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime maxRequestLength="2147483647" executionTimeout="3600"/>
<membership defaultProvider="xplProvider">
<providers>
<add name="xplProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="10" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<customErrors mode="RemoteOnly" defaultRedirect="~/sysError.aspx">
<error statusCode="404" redirect="~/infoCollector.aspx"/>
</customErrors>
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="Static"/>
</system.web>
<system.webServer>
<handlers>
<add name="DocImage" verb="GET,POST" path="DocImage.axd" type="DotnetDaddy.DocumentViewer.DocImageHandler, DocumentViewer"/>
<add name="pngs" verb="*" path="ClientPortals/images/*" type="Project.UserInterface.ClientPortals.image" preCondition="managedHandler"/>
</handlers>
<modules>
<add name="UploadModule" type="RTE.UploadModule,RichTextEditor"/>
<add name="CuteEditor.UploadModule" type="CuteEditor.UploadModule,CuteEditor"/>
</modules>
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
<remove statusCode="404"/>
<error statusCode="404" path="/scenter.aspx" responseMode="ExecuteURL"/>
</httpErrors>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967296"/>
</requestFiltering>
</security>
</system.webServer>
<appSettings>
<add key="PageInspector:ServerCodeMappingSupport" value="Disabled"/>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ServiceSoap">
<security mode="Transport"/>
</binding>
<binding name="ServiceSoap1"/>
<binding name="sms2SOAPbasicHttpBinding"/>
<binding name="sms2SOAPbasicHttpsBinding">
<security mode="Transport"/>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="sms2wsHttpBinding">
<security mode="None"/>
</binding>
<binding name="sms2wsHttpBindingSecure">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://api.authorize.net/soap/v1/Service.asmx" binding="basicHttpBinding" bindingConfiguration="ServiceSoap" contract="ArbApiSoap.ServiceSoap" name="ServiceSoap"/>
<endpoint address="http://sms2.cdyne.com/sms.svc/Soap" binding="basicHttpBinding" bindingConfiguration="sms2SOAPbasicHttpBinding" contract="cdyneSMS.Isms" name="sms2SOAPbasicHttpBinding"/>
<endpoint address="https://sms2.cdyne.com/sms.svc/SecureSoap" binding="basicHttpBinding" bindingConfiguration="sms2SOAPbasicHttpsBinding" contract="cdyneSMS.Isms" name="sms2SOAPbasicHttpsBinding"/>
<endpoint address="http://sms2.cdyne.com/sms.svc/WS" binding="wsHttpBinding" bindingConfiguration="sms2wsHttpBinding" contract="cdyneSMS.Isms" name="sms2wsHttpBinding"/>
<endpoint address="https://sms2.cdyne.com/sms.svc/WS" binding="wsHttpBinding" bindingConfiguration="sms2wsHttpBindingSecure" contract="cdyneSMS.Isms" name="sms2wsHttpBindingSecure"/>
</client>
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="AWSSDK" publicKeyToken="9f476d3089b52be3" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.3.55.0" newVersion="2.3.55.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<microsoft.web.services3>
<messaging>
<executionTimeoutInSeconds value="300" />
<maxMessageLength value="524288000" />
</messaging>
</microsoft.web.services3>
</configuration>
`
答案 0 :(得分:4)
maxRequestLength
位于 Kilobyte 不是字节,所以2147483647 Kilobytes大约是2000 GB。 2GB = 2097152 KB。尝试将其更改为2097152
另一方面,maxAllowedContentLength
以字节为单位。
建议将这两个值放在web.config中。
maxRequestLength表示ASP.NET支持的最大文件上载大小,maxAllowedContentLength指定IIS支持的请求中的最大内容长度。因此,我们需要设置maxRequestLength和maxAllowedContentLength值来上传大文件。
<system.web>
<httpRuntime maxRequestLength="2097152" executionTimeout="3600"/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>