Solve the problem that the uploaded pictures or files in the. net project are too large to upload

  • 2021-08-31 07:36:08
  • OfStack

Recently, when doing the project, the user proposed to upload a large picture. One picture may be 10 megabytes. The upload control of the third party originally used has the setting of limiting the upload size of the picture

The previous setting is 2M. According to the user's requirements, it is OK to change the setting of limiting the upload size of pictures directly, but when uploading large pictures,

Always abnormal:

Error message: Maximum request length exceeded

Solution:

Error cause: asp. net default maximum upload file size is 4M and run timeout is 90S.

Modify the configuration in web. config


<configuration> 
 <system.web> 
 <httpRuntime useFullyQualifiedRedirectUrl="true" executionTimeout="120" maxRequestLength="2097151"/>
 </system.web> 
<configuration> 

In my project, it is no problem to upload this modification after a simple explanation:

executionTimeout执行超时时间:单位是秒

maxRequestLength上传的最大长度:上面我设置的已经是最大的数值了  单位为KB

ps: The following is the complete configuration of httpRuntime and related explanations


 <httpRuntime executionTimeout="600" maxRequestLength="951200" 
 useFullyQualifiedRedirectUrl="true" minFreeThreads="8" 
 minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/> 

httpRuntime is to configure asp. net http run settings to determine how requests to asp. net applications are handled.

executionTimeout: Indicates the maximum time limit allowed to execute a request, in seconds

maxRequestLength: Indicates the maximum file upload size supported by asp. net. This display can be used to prevent denial-of-service attacks caused by users passing large numbers of files to the server. The specified size is in KB. The default value is 4096KB.

userFullyQualifiedRedirectUrl: Indicates whether the client redirection is fully qualified (in the format "http://server/path", which is required for some mobile controls), or whether a relative redirection is sent to the client instead. If true, all non-fully qualified redirects are automatically converted to the fully qualified format. false is the default option.

minFreeThreads: Specifies the minimum number of free threads allowed to execute new requests. ASP. NET A specified number of threads remain free to require additional threads to complete their processing requests. The default value is 8.

minLocalRequestFreeThreads: Represents the minimum number of free threads that ASP. NET maintains that are allowed to execute new local requests. This number of threads is reserved for incoming requests from the local host in case some requests make sub-requests to the local host during their processing. This avoids deadlocks that may result from recursive re-entry into the web server.

enableVersionHeader: Indicates whether the specified ASP. NET should output the version header. vs 2005 uses this property to determine which version of ASP. NET is currently in use. For production environments, this property is not required and can be disabled.


Related articles: