Why does WebClient.UploadFileAsync not work with large file downloads?

I upload a file from a C # application to an ASP.Net website, both written by me, so I have access to the code.

But it works for a text file (1 KB), but not for a MOV file (77 MB).

In both cases, I use UploadProgressChanged to make progress. The TXT file goes 100%, and the MOV file only up to 50%. When this is done, I will find only the TXT file stored on the server, but not the MOV file.

Why is this happening? How can I make it work?

Windows Application Code - C #

Client.UploadFileAsync(new Uri("http://localhost:xxxxxx/Default.aspx"), "c:\\1.MOV"); 

The default code .aspx is VB

 Protected Sub Page_Load(...) Handles Me.Load If Request.Files IsNot Nothing Then If Request.Files.Count > 0 Then Request.Files(0).SaveAs(Server.MapPath("~/1.mov")) Response.Write("File saved at: " + Server.MapPath("~/1.mov")) Else Response.Write("At least one file should be sent") End If Else Response.Write("No file received") End If End Sub 
+1
source share
2 answers

You can change the default limit (4 MB) in a localized way by dropping the web.config file in the directory in which your download page lives. Thus, you do not need to allow huge downloads to your entire site (this can open you certain types of attacks).

Here is an example from a production application. This parameter is set for 100mb:

 <configuration> <system.web> <httpRuntime maxRequestLength="100000" executionTimeout="600" /> </system.web> </configuration> 
+3
source

The exception is thrown when the specified value is less than 1 kilobyte and exceeds 4194304 kilobytes (4 GB).

0
source

Source: https://habr.com/ru/post/888707/


All Articles