.net 在 iis6 中增加文件上传大小限制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/383781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Increase file upload size limit in iis6
提问by JustLogic
Is there any other place besides the metabase.xml file where the file upload size can be modified?
除了metabase.xml文件,还有其他地方可以修改文件上传大小吗?
I am currently running a staging server with IIS6 and it is setup to allow uploading of files up to 20mb. This works perfectly fine. I have a new production server where I am trying to setup this same available size limit. So I edited the metabase.xml file and set it to 20971520. Then I restarted IIS and that didn't work. So I then restarted the entire server, that also didn't work. I can upload files around 2mb so it is definitely allowing file sizes larger then the standard 200kb default size. I try uploading a 5mb file and my upload.aspx page completely crashes. Is it possible there is something else I need to configure? The production server is located on a server farm, could there be some limits set on there end?
我目前正在使用 IIS6 运行一个临时服务器,它被设置为允许上传最大 20mb 的文件。这工作得很好。我有一个新的生产服务器,我试图在其中设置相同的可用大小限制。所以我编辑了 metabase.xml 文件并将其设置为 20971520。然后我重新启动了 IIS,但没有奏效。所以我然后重新启动了整个服务器,这也不起作用。我可以上传大约 2mb 的文件,所以它绝对允许文件大小大于标准的 200kb 默认大小。我尝试上传一个 5mb 的文件,但我的 upload.aspx 页面完全崩溃了。是否有可能我需要配置其他东西?生产服务器位于服务器群中,是否可以在那里设置一些限制?
Thanks
谢谢
采纳答案by Carl
回答by netadictos
I will extend my answer to your question to take into account other possible situations.
我将扩展我对您的问题的回答,以考虑其他可能的情况。
A very good link to learn about uploading big size files is this one: http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx
了解上传大文件的一个很好的链接是:http: //weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx
Here Jon Galloway explains the best techniques to treat the problem:
在此 Jon Galloway 解释了处理该问题的最佳技术:
1.-Changing machine config or web.config:
1.-更改机器配置或 web.config:
<system.web>
<httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>
Here you change not only the maxRequestLength, but you must give more seconds for the executionTimeout.
在这里,您不仅要更改 maxRequestLength,还必须为 executionTimeout 提供更多秒数。
Interesting thing: Take into account that the value of this setting is ignored in debug mode. The default in .NET Framework 2.0 is 110 seconds. In the .NET Framework 1.0 and 1.1, the default is 90 seconds.
有趣的事情:考虑到此设置的值在调试模式下被忽略。.NET Framework 2.0 中的默认值为 110 秒。在 .NET Framework 1.0 和 1.1 中,默认值为 90 秒。
2.-Talking about the real solution, HttpModules like the free of charge NeatUpload
2.-谈真正的解决方案,HttpModules喜欢免费的NeatUpload
3.-Explaining another way of uploading more intuitively: Silverlight or flash swfupload
3.-更直观的解释另一种上传方式:Silverlight或flash swfupload
4.-He speaks about one restriction II7 has. In this page http://www.telerik.com/help/aspnet-ajax/upload_uploadinglargefiles.htmlyou can find more interesting settings for IIS 7, to set a maximum of 100 megas. You add:
4.-他谈到了 II7 的一个限制。在这个页面http://www.telerik.com/help/aspnet-ajax/upload_uploadinglargefiles.html你可以找到更多关于 IIS 7 的有趣设置,设置最大 100 megas。你补充:
<system.webServer>
...
<security >
<requestFiltering>
<requestLimits maxAllowedContentLength="1024000000" />
</requestFiltering>
</security>
</system.webServer>
And you must open the file C:\Windows\System32\inetsrv\config\applicationHost.config and find the line:
并且您必须打开文件 C:\Windows\System32\inetsrv\config\applicationHost.config 并找到以下行:
<section name="requestFiltering" overrideModeDefault="Deny" />
changing to:
更改为:
<section name="requestFiltering" overrideModeDefault="Allow" />
Another interesting thing Galloway mentions: "In ASP.NET 1.0 and 1.1, the entire file was loaded into memory before being written to disk. There were improvements in ASP.NET 2.0 to stream the file to disk during the upload process."
Galloway 提到的另一件有趣的事情是:“在 ASP.NET 1.0 和 1.1 中,整个文件在写入磁盘之前先加载到内存中。ASP.NET 2.0 中有一些改进,可以在上传过程中将文件流式传输到磁盘。”
For IIS6 the solution Chris gives I think is appropriate:
对于 IIS6,我认为 Chris 给出的解决方案是合适的:
http://www.banmanpro.com/support2/File_Upload_limits.asp
http://www.banmanpro.com/support2/File_Upload_limits.asp
Another source:
另一个来源:
Another URL where one user has tested a lot of components here:
另一个用户在这里测试了很多组件的 URL:
http://remy.supertext.ch/2008/01/file-upload-with-aspnet/
http://remy.supertext.ch/2008/01/file-upload-with-aspnet/
He refers to a codeproject project (!) that is another very good example of using large files and flash here:
他引用了一个 codeproject 项目(!),这是另一个使用大文件和 flash 的很好的例子:
回答by Hewins
I have been struggling with this issue for hours now and finally have solved my particular problem and I want to share it here.
我已经为这个问题苦苦挣扎了几个小时,终于解决了我的特定问题,我想在这里分享。
If you are using urlscan, there is a file size limit in its configuration as well. To make changes to that, you need to edit the file "UrlScan.ini" located (typically) at:
如果您使用urlscan,则其配置中也有文件大小限制。要对此进行更改,您需要编辑位于(通常)以下位置的文件“UrlScan.ini”:
C:\WINDOWS\system32\inetsrv\urlscan
C:\WINDOWS\system32\inetsrv\urlscan
Change the value for "MaxAllowedContentLength" to your desired max file size value.
将“ MaxAllowedContentLength”的值更改为所需的最大文件大小值。
回答by Hewins
If you are uploading document from rad-control than you can just use this line of code.
如果您从 rad-control 上传文档,则可以使用这行代码。
RadFileExplorer1.Configuration.MaxUploadFileSize = 2000 * 1024;
It worked for me.
它对我有用。

