Asp.net generally processes the problem that the program receives the uploaded files. asp.net uploads files.

Source: Internet
Author: User

Asp.net generally processes the problem that the program receives the uploaded files. asp.net uploads files.

When Html + ashx is used to process file uploads, the problem that the file to be uploaded exceeds 4 MB occurs. The first HTML code is as follows:

<! DOCTYPE html> View Code

The general processing program UpLoadHandler. ashx code is as follows:

Using System; using System. collections. generic; using System. IO; using System. linq; using System. web; namespace Zhong. summary of Web {// <summary> /// UpLoadHandler // </summary> public class UpLoadHandler: IHttpHandler {public void ProcessRequest (HttpContext context) {context. response. contentType = "text/plain"; // obtain all uploaded files // if the size of the uploaded file exceeds 4 MB, an exception [exceeds the maximum request length.], In the Web. config: Configure HttpFileCollection. request. files; // if it is a private key. if the value of Count is 0, the request is directly sent to the ashx handler for (int I = 0; I View Code

When uploading a file larger than 4 MB, the exception is as follows:

 

You can modify the file upload size limit by configuring web. config.

<? Xml version = "1.0" encoding = "UTF-8"?> <! -- For more information about how to configure ASP. NET applications, visit the http://go.microsoft.com/fwlink? LinkId = 169433 --> <configuration> <system. web> <! -- The unit of maxRequestLength is kb. The maximum length cannot exceed 2097151 Kb, that is, 4 GB. The executionTimeout operation times out, the Unit is seconds --> 

A line is added here

 

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.