Web.Config file configuration properties that limit the size and time of uploaded files

  • 2020-05-26 08:09:57
  • OfStack

In the mail sending system or other web sites that send files, users are limited in the size of the files they can send, because this not only saves space on the server, but also improves the speed of sending files. Here's how to configure limits on upload size and time in the Web.Config file.

The Web.Config file is configured to limit the upload file size and time string when in the Web.Config file < httpRuntime > < httpRuntime/ > To do this, you need to set the following two properties:
maxRequestLength properties: used to prevent server attacks, such as denied access because a user sends a large file to the server. The default is 4096 (4MB)
ExecutionTimeout property: specifies the maximum number of seconds allowed to execute a request before the ASP.NET application is automatically closed. This timeout attribute applies only if the debug attribute in the compilation element is False. The default value is 110s.

In web. The config < system.web > < /system.web > The following code is added inside:
< !--
Used to support uploading large files, 4M is supported by default, now modified to 400M
httpRuntime is to configure the asp.net http runtime Settings to determine how to process requests to the asp.net application.
executionTimeout: represents the maximum time limit in seconds allowed to execute a request
maxRequestLength: indicates the maximum file upload size supported by ASP.NET. This restriction can be used to prevent denial-of-service attacks caused by users passing a large number of files to the server. The specified size is in units of KB. The default value is 4096 KB (4 MB).
useFullyQualifiedRedirectUrl: indicates whether the client redirection is fully qualified (in the "http://server/path" format, which is required for some mobile controls), or whether the relative redirection is sent to the client instead. If it is True, all non-fully qualified redirects are automatically converted to fully qualified formats. false is the default option.
minFreeThreads: specifies the minimum number of free threads allowed to execute new requests. ASP.NET leaves a specified number of threads in a free state for the purpose of requiring additional threads to complete a request for its processing. The default value is 8.
minLocalRequestFreeThreads: represents the minimum number of free threads that ASP.NET maintains to allow the execution of new local requests. This number of threads is reserved for requests coming in from the localhost in case some request makes a subrequest to the localhost during its processing. This avoids possible deadlocks caused by recursive re-entry into the Web server.
appRequestQueueLimit: represents the maximum number of requests that ASP.NET will queue for the application. Requests are queued when there are not enough free threads to process them. When the queue exceeds the limits specified in this setting, incoming requests are rejected with the "503-server too busy" error message.
enableVersionHeader: specifies whether ASP.NET should output version headers. Microsoft Visual Studio 2005 USES this property to determine which version of ASP.NET is currently in use. This property is not required for a production environment and can be disabled.
-- >

<httpRuntime executionTimeout="500" maxRequestLength="409600" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" /> 

Related articles: