3

I am trying to upload large files, size is more than 28 mb (this is the default request size in .net core). I have reed a lot of articles and official documentation but without any luck. I have tried with html form:

<form asp-action="Upload" asp-controller="Media" method="post" enctype="multipart/form-data">
   <input type="file" name="files" multiple id="inputId" />
   <button type="submit">Ok</button>
</form>

and jQuery AJAX reuqest:

function uploadFiles(inputId) {
    var input = document.getElementById('inputId');
    var files = input.files;
    var formData = new FormData();
    for (var i = 0; i != files.length; i++) {
      formData.append("files", files[i]);
    }
    $.ajax({
      url: "/uploader",
      data: formData,
      processData: false,
      contentType: false,
      type: "POST",
      success: function (data) {
        alert("Files Uploaded!");
      }
    });
};

My action looks like:

 [DisableRequestSizeLimit]
 public class MediaController : Controller
 {
    [HttpPost]
    public async Task<IActionResult> Upload(IEnumerable<IFormFile> files)
    {
    }
 }

This is a part of my code, sorry if there is some type-o. When I run it locally, there is no problem, I am able to upload file large that 28mb., but when I published it on Azure Web App, I cannot upload file large than 28mb. and it throws 404.13 Error. Tried to change startup.cs and program.cs to add form options and request body size limits but without success. Then I tried different method, opened ftp and manually changed the web.config file (added some xml line of codes for request body size and etc.) After these changes, everything was working. After some days trying to figure it out by myself, decide to post a article with my problem. If some one has some solution, please share it. Thanks guys.

S.K.
  • 163
  • 3
  • 9

0 Answers0