Maximum ASP.Net MVC request size

6

I'm uploading Image using JQuery.

I have limited the image to a maximum of 2mb, however when I send an image larger than 2mb, an exception is made saying Maximum request size exceeded.

What I did:

function fileUpload() {
    
    $('#fileupload').fileupload();
    $('#fileupload').fileupload('option', {
        maxFileSize: 1024 * 1024,
        autoupload: true
    });

    var uploadFinished = function (e, data) {
        if (data.files[0].size > 2000000) { // 2mb
            $.notify("Faça o upload de uma imagem de até 2MB", "danger");
            jqXHR.abort();
            return
        }

        var img = $("#inpLogoNameNew").val();
        $("#imgLogo").show();
        $("#imgWhite").hide();
        $("#imgLogo").attr("src", (data.result.imgx64));
        $("#inpLogoNameNew").val(data.result.Name);

        if ($("#inpLogoNameOld").val() !== $("#inpLogoNameNew").val() &&
            img !== $("#inpLogoNameNew").val() &&
            img !== $("#inpLogoNameOld").val()) {
            deleteLogo(img);
        }

    };
    $('#fileupload')
        .bind('fileuploaddone', uploadFinished);
}
<form id="fileupload" action="@Url.Action("UploadFiles")" method="POST" enctype="multipart/form-data">
                    <span id="spanUpload" class="btn btn-primary btn-sm fileinput-button"><i class="icon-plus icon-white"></i><span>Foto</span>
                        <input id="inpLogo" type="file" name="files[]"/>
                    </span>
                </form>
    
asked by Ademilton Marcelo Nunes 30.03.2016 в 22:23

4 answers

6

In% w / o, set the following:

<configuration>
  ...
  </system.webServer>
    ...
    <security>
      <requestFiltering>
        <!-- max 1GB -->
        <requestLimits maxAllowedContentLength="1000000000" />
      </requestFiltering>
    </security>
    ...
  </system.webServer>
  ...
</configuration>
    
30.03.2016 / 23:08
2

I was having the same problem and could not solve with the Gypsy solution. I solved by inserting the following code in web.config :

<httpRuntime 
executionTimeout="90" 
maxRequestLength="4096" //aumentar o valor aqui
useFullyQualifiedRedirectUrl="false" 
minFreeThreads="8" 
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
/>

I'll leave it safe here to help other people as well.

    
05.10.2017 в 16:43
0

Just make the change in your web.config , by doing so:

< system.web><br>
    < httpRuntime maxRequestLength="10240"/> <br>
< / system.web>

The value is set to kilobytes and the default is 4096, that is, 4 megabytes. Above, for example, the maximum size was set to 10 megabytes.

    
22.12.2017 в 14:06
0

In web config, a configuration already exists:

<system.web>
<httpRuntime targetFramework="4.5"/>
</system.web>

Just change it, it will look like this:

<system.web>
<httpRuntime targetFramework="4.5" maxRequestLength="10485760"/>
</system.web>

This works

    
23.10.2018 в 15:25