gpt4 book ai didi

c# - ASP.NET 文件上传控件允许的最大文件大小

转载 作者:太空狗 更新时间:2023-10-29 21:40:12 26 4
gpt4 key购买 nike

我在 ASP.Net 中使用文件上传控件,遵循以下博客方法。

http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx

默认值 4MB 在 machine.config 中设置,但您可以在 web.config 中覆盖它。例如,要将上传限制扩大到 20MB,您可以这样做:

<system.web>
<httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>

问题: 如果我们还允许用户上传 50-60 MB 的文件,我可以将请求的长度增加到什么级别(最大大小),以及对网站性能的影响。

最佳答案

maxRequestLength 字段的“理论”最大级别是有符号 32 位整数数据类型 (Int32.MaxValue) 的最大值。

但是,您将必须测试上传以了解您的性能。

编辑:

来自 a Microsoft support ticket :

Theoretically, the maximum file upload size is fairly large. However, because of ASP.NET health monitoring, you cannot upload very large files in ASP.NET. The ASP.NET worker process has a virtual address space of 2 gigabytes (GB). However, the ASP.NET worker process only uses a little more than 1 GB because of health monitoring and memory fragmentation.

During the upload process, ASP.NET loads the whole file in memory before the user can save the file to the disk. Therefore, the process may recycle because of the memoryLimit attribute of the processModel tag in the Machine.config file. The memoryLimit attribute specifies the percentage of physical memory that the ASP.NET worker process can exhaust before the process is automatically recycled. Recycling prevents memory leaks from causing ASP.NET to crash or to stop responding.

Additionally, other factors play a role in the maximum file size that can be uploaded. These factors include available memory, available hard disk space, processor speed, and current network traffic. With regular traffic of files being uploaded, Microsoft recommends that you use a maximum file size in the range of 10 to 20 megabytes (MB). If you rarely upload files, the maximum file size may be 100 MB.

Note You can upload files that are larger than 100 MB in ASP.NET. However, Microsoft recommends that you follow the maximum file upload sizes that are mentioned in this article. To determine more precise file sizes, perform stress testing on computers that are similar to the ones that will be used in production.

关于c# - ASP.NET 文件上传控件允许的最大文件大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15248934/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com