How to solve the problem of uploading pictures or files that are too large to upload in a. NET project

Source: Internet
Author: User
Tags file upload

Recently did the project when the user proposed to upload a large picture a picture may be more than 10 trillion originally used by the third party upload control has limited picture upload size settings

Previously set is 2M in accordance with the requirements of users that directly limit the size of the picture upload settings can be changed, but when uploading large pictures is always abnormal:

error message : exceeds maximum request length

Solution :

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

modifying configuration in Web.config

<configuration>
<system.web>
Usefullyqualifiedredirecturl= "true" executiontimeout= "
</system.web>
<configuration>

  after this change in my project, it's no problem to upload. Simple explanation :

Executiontimeout Execution timeout: unit is seconds
maxRequestLength Upload Maximum length: The above I set is already the largest number of units in KB

PS: Here is the httpruntime complete configuration and related explanations

Usefullyqualifiedredirecturl= "true" minfreethreads= "8"

Minlocalrequestfreethreads= "4" apprequestqueuelimit= "enableversionheader=" "true"/>

HttpRuntime is to configure the ASP.net HTTP run settings to determine how to handle requests for asp.net applications.

Executiontimeout: Represents the maximum time limit, in seconds, that a request is allowed to execute

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

Userfullyqualifiedredirecturl: Indicates whether client redirection is fully qualified (in the form of "Http://server/path", which is necessary for some mobile controls), or whether relative redirection is sent to the client instead. If true, all redirects that are not fully qualified are automatically converted to fully qualified formats. False is the default option.

minFreeThreads: Specifies the minimum number of free threads that are allowed to execute new requests. Asp. NET maintains a free state for a specified number of threads that require additional threads to complete their processing requests. The default value is 8.

minLocalRequestFreeThreads: Represents the minimum number of free threads that the ASP.net maintains to allow the execution of new local requests. The number of threads is reserved for incoming requests from the local host in case some requests issue a child request to the local host during its processing. This avoids deadlocks that may be caused by recursion to re-enter the Web server.

Enableversionheader: Indicates whether the specified asp.net should output a version of the header. VS2005 uses this property to determine the current use of the ASP.net version. For a production environment, this property is not required and can be disabled.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.