2016-05-24 65 views
0

我從ASP.Net網站收到關於使用AJAX提交大文件2GB的錯誤請求。HTTP錯誤400 - 使用AJAX上傳大文件時的錯誤請求

我的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> 

`

回答

2

maxRequestLength千字節不是字節這樣2147483647千字節大約是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> 
+0

感謝小羅的suggetion 但是,增加的requestFiltering標籤,我總是得到500 – pawanplus

+0

你可以發佈你的web.config代碼後? –

+0

在帖子中添加了配置文件。請幫助 – pawanplus