文件上传元素出现问题 [英] Problem with file upload element
问题描述
你好,
我目前在文件上传元素上遇到问题.我正在使用Visual Studio 2010 Express.
如果我尝试上传一个大文件(〜4 MB),则什么也没有发生.而是显示无法显示此页面",就像出现连接问题一样.
对于较小的文件,它确实可以正常工作.
调试时,我发现甚至没有调用上载按钮事件处理程序的第一行.
有人可以帮我吗?
谢谢
^ ]
那是因为默认情况下,asp.net允许您上传最大文件大小为4096kb.
您需要在您的web.config中进行更改
添加
<httpruntime></httpruntime>
web.config中的节点
并将maxRequestLength设置为您需要上传的文件的最大大小(以字节为单位).
<httpruntime maxrequestlenght="8192" executiontimeout="400" />
maxRequestLenght是您要上传的文件的最大大小.
这应该为您解决问题.但是,如果您通过将大文件分成小块并在服务器上加入小块来上传大文件,这是一个好习惯.
要更改此大小限制,您可以在web.config
.comments(可在C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG)
的ASP.NET 2.0配置文件夹中找到)或应用程序的web.config文件中进行一些更改.
在web.config.comments文件中,找到一个名为< httpRuntime>的节点.如下所示:
复制
< httpRuntime executionTimeout = " maxRequestLength = " requestLengthDiskThreshold = " useFullyQualifiedRedirectUrl = " minFreeThreads = " minLocalRequestFreeThreads = " appRequestQueueLimit = " enableKernelOutputCache = " enableVersionHeader = " requireRootedSaveAsPath = " enable = " shutdownTimeout = " delayNotificationTimeout = " waitChangeNotification = " maxWaitChangeNotification = " enableHeaderChecking = " sendCacheControlHeader = " apartmentThreading = " />
>
Hallo,
I am currently having a problem with a file upload element. I am using Visual Studio 2010 Express.
If I try to upload a large file (~ 4 MB), nothing happens. Instead "this page cannot be displayed" is shown, as if there were connection issues.
It does work fine for smaller files.
When debugging, I found out that not even the first line of the upload button event handler is called.
Can someone help me?
Thanks
Upload large file in asp.net mvc[^]
That''s because By default asp.net allows u to upload a file of maximum size 4096kb.
u need to do changes in your web.config
add
<httpruntime></httpruntime>
node in web.config
and set maxRequestLength to whatever the max size of the file you need to upload in bytes.
<httpruntime maxrequestlenght="8192" executiontimeout="400" />
maxRequestLenght is the max size of the file u want to upload.
this should do the trick for you However it''s a good practice if u upload your large file by dividing it into pieces and joining the pieces at server.
To change this size limit, you make some changes in either theweb.config
.comments (found in the ASP.NET 2.0 configuration folder atC:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG)
or your application''s web.config file.
In the web.config.comments file, find a node called <httpRuntime> that looks like the following:
Copy
<httpRuntime executionTimeout="110" maxRequestLength="4096" requestLengthDiskThreshold="80" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="5000" enableKernelOutputCache="true" enableVersionHeader="true" requireRootedSaveAsPath="true" enable="true" shutdownTimeout="90" delayNotificationTimeout="5" waitChangeNotification="0" maxWaitChangeNotification="0" enableHeaderChecking="true" sendCacheControlHeader="true" apartmentThreading="false" />
这篇关于文件上传元素出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!