问题描述
我正在将文件从C#应用程序上载到ASP.Net网站,两者均由我编写,因此我可以访问代码.
I am uploading a file from a C# application to an ASP.Net website, both written by me so I have access to the code.
但是,它只能用于文本文件(1KB),而不能用于MOV文件(77MB).
But, it is working for a text file (1KB) but not for a MOV file (77MB).
在两种情况下,我都使用UploadProgressChanged来获取进度.TXT文件达到100%,而MOV文件仅达到50%.完成后,我只能找到服务器上保存的TXT文件,而找不到MOV文件.
In both cases, I am using UploadProgressChanged to get the progress. The TXT file goes to 100% while the MOV file goes only till 50%. When done, I only find the TXT file saved on the server but not the MOV file.
为什么会这样?我如何使它工作?
Why is this happening? How can I get it to work?
Windows应用代码-C#
Client.UploadFileAsync(new Uri("http://localhost:xxxxxx/Default.aspx"), "c:\\1.MOV");
Default.aspx代码-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
推荐答案
这是生产应用程序中的一个示例.设置为100mb:
Here's an example from a production app. This one is set for 100mb:
<configuration>
<system.web>
<httpRuntime maxRequestLength="100000" executionTimeout="600" />
</system.web>
</configuration>
这篇关于为什么WebClient.UploadFileAsync无法处理大文件上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!