0

I have a website (ASP.NET core) with an ajax + base64 function to upload files.

When I pick a file from 0-29 MB aprox works perfect, but If i pick a larger file, does not upload.

My web.configs;

Web.config (app side)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\AppName.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true">
      <environmentVariables />
    </aspNetCore>
    <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
        <rewrite>
            <rules>
                <rule name="HTTP A HTTPS" enabled="false" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
  </system.webServer>
    <system.web>
     <!--    <httpRuntime maxRequestLength="2147483647" /> -->
    </system.web>
</configuration>

And web.config (webservice)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appSettings>
    <add key="..." value=".....=" />
    <add key="..." value=".....=" />
    <add key="..." value=".....=" />
    <add key="..." value=".....=" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <authentication mode="Windows" />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
      <httpRuntime maxRequestLength="2147483647" maxQueryStringLength="2097151" />
  </system.web>
  <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>
</configuration>

I tried some parameters that I found in other questions like this. maxAllowedContentLength,maxRequestLength, maxUrlLenght... but any works.

I think maxAllowedContentLength="1073741824" should be 1 GB aprox.

But I do not if it is correct.Neither if change would be in web.config site,web.config webserver or both.

Any idea?

Thanks!!

josemb94
  • 23
  • 6
  • It seems that you are hosting the request under kestrel middleware. Have you tried to modify maxrequestbody?https://stackoverflow.com/questions/38698350/increase-upload-file-size-in-asp-net-core – Jokies Ding Apr 22 '20 at 05:25
  • Yes, I set; public void ConfigureServices(IServiceCollection services) { services.Configure(options => { options.Limits.MaxRequestBodySize = int.MaxValue; }); – josemb94 Feb 22 '21 at 14:45

0 Answers0