ASP.NET MVC - how to upload a file with more than 5mb using ajax?

I am using the following code to upload files:

HTML:

<form action="/Employee/FileUpload?UnityId=1&amp;ObjectId=1" data-ajax="true" data-ajax-failure="OnFailure" data-ajax-method="Post" data-ajax-success="OnSuccess" enctype="multipart/form-data" id="form6" method="post" class="MultiFile-intercepted"><div class="card default">
    <input multiple type="file" tabindex="-1" name="File" required title=" " autocomplete="off" maxlength="10" onchange="this.setCustomValidity('')" data-maxsize="10240" class="multi custom-file-input" accept=".bmp,.jpeg,.jpg,.pdf,.xls,.xlsx,.csv,.txt,.mp4,.mkv,.avi,.wmv,.mp3,.3gp,.doc,.docx">
    <input id="file" name="submit" role="button" type="submit" class="btn btn-primary validate-form upload-archive" tabindex="0" value="Enviar" />
</form>

JQUERY:

$(function () {
$("#form6").submit(function (event) {
    var dataString;
    event.preventDefault();
    var action = $("#form6").attr("action");
    if ($("#form6").attr("enctype") == "multipart/form-data") {

        dataString = new FormData($("#form6").get(0));
        contentType = false;
        processData = false;
    } else {

    }
    $.ajax({
        type: "POST",
        url: action,
        data: dataString,
        dataType: "json",
        contentType: contentType,
        processData: processData,
        success: function (data) {

        },
        error: function (jqXHR, textStatus, errorThrown) {

            alert("fail");
        }
    });
});

});

CONTROLLER:

    [HttpPost]
    public ActionResult FileUpload(string ObjectId, string UnityId, HttpPostedFileBase File)
    {
         .. Meu código
    }

With this code I am able to upload files up to 5MB, however when I try to upload one of 9mb the code does not work, the controller is not even called and no error message is displayed.

Is there any limit to uploading files using this method?

How can I solve this problem?

Author: Diego Silva, 2018-10-25

1 answers

This limitation is asp, to change it just change the parameterization in your web file.config, example:

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="xxx" />
  </system.web>
</configuration>
 1
Author: Lucas Miranda, 2018-10-25 21:43:02