This is a migrated thread and some comments may be shown as answers.

404 Error file size 40 MB

4 Answers 766 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 05 Mar 2020, 03:45 PM

Hello,

I can't figure out why the .net core 2.2 / Angular 8 application throw 404 error when trying to upload 40 MB file using the kendo-upload. The request didn't hit the API, it throw 404 error on the client. I'm able to upload 21 MB file, i have not attempt 30, i assumed it will work up to 30 MB based on the default body size of the post request. here the error

Access to XMLHttpRequest at 'https://web-api' from origin 'https://web-client' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

HTTP Response : 404

 

I had attempted to

- set the MaxRequestBodySize to 50 MB in UseKestrel

- set [RequestSizeLimit(50000000)] to the API method

- update the web.config requestLimits maxAllowedContentLength="52428800"

- use [chunkable] in kendo-upload

 

Something to do with chunk? or some setting in Angular? setting in kendo-upload?

 

 

Thanks,

Bryian Tan

4 Answers, 1 is accepted

Sort by
0
Accepted
Svet
Telerik team
answered on 09 Mar 2020, 11:50 AM

Hi Bryian,

Thank your for the reaching out to us.

I managed to reproduce a 404 error when uploading large files ( > 30mb) using the following project:

https://github.com/telerik/kendo-angular/tree/master/examples-standalone/aspnetcore-upload

Indeed, the issue seems to be caused by ASP.NET Core rather than by Kendo UI for Angular. What I did in order to avoid the error is to add a web.config file where I specify the maxAllowedContentLength:

 

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- To customize the asp.net core module uncomment and edit the following section. 
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  <system.webServer>
    <handlers>
      <remove name="aspNetCore" />
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
      <environmentVariables>
        <environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44364" />
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
      </environmentVariables>
    </aspNetCore>
    <security>
      <requestFiltering>
        <!--The default size is 30000000 bytes (28.6 MB). MaxValue is 4294967295 bytes (4 GB)-->
        <!-- 100 MB in bytes -->
        <requestLimits maxAllowedContentLength="104857600" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

 

and I also had to add the [DisableRequestSizeLimit] attribute to the controller handling the upload request in order to avoid a subsequent error:

 

  public class StreamingController : Controller
    {

        private readonly IWebHostEnvironment _webHhostingEnvironment;

        public StreamingController(IWebHostEnvironment webHostingEnvironment)
        {
            _webHhostingEnvironment = webHostingEnvironment;
        }

        [Route("api/Upload")]
        [HttpPost]
        [DisableRequestSizeLimit]
        public async Task<IActionResult> OnPostUploadAsync(List<IFormFile> files)
...

 

Please check the following announcement from the official aspnet GitHub repository for some more details on the topic:

https://github.com/aspnet/Announcements/issues/267

I am also attaching an example project using the suggestions.

I hope this helps. In case the issue persists on your side, could you provide a sample project or some code demonstrating the implementation on your side that will help us to reproduce the issue. Thank you in advance.

Regards,
Svetlin
Progress Telerik

Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Patrick
Top achievements
Rank 1
answered on 10 Mar 2020, 02:28 AM

Svetlin,

Thanks. I'll give it another try.

 

Thanks,

Bryian Ta

0
Svet
Telerik team
answered on 11 Mar 2020, 09:14 AM

Hi Bryian,

Sure, take your time. Please let us know in case further assistance is required for this case. Thank you in advance.

Regards,
Svetlin
Progress Telerik

Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Patrick
Top achievements
Rank 1
answered on 05 May 2020, 09:01 PM

I have time to look into this issue again. Look like I was using a wrong test case. I upload a 40MB file but didn't factor in the body content length during the POST. In web.config, I set the maxAllowedContentLength to exactly 40MB, but it should be higher than 40MB because the ContentLength = upload files and body content during POST. The above solution works fine.

 

Thanks,

Bryian Tan

Tags
Upload
Asked by
Patrick
Top achievements
Rank 1
Answers by
Svet
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or