To modify the Webcong file:
The following is the referenced content:
<system.web>
Which is closely related to uploading:
maxRequestLength
Indicates the maximum file upload size supported by ASP.
This restriction can be used to prevent denial of service attacks that result from the user passing a large number of files to the server.
The specified size is in kilobytes.
The default value is 4096 KB (4 MB).
Executiontimeout
Indicates the maximum number of seconds that a request is allowed to execute before it is automatically closed by ASP.
Units in seconds, when uploading large files, set this larger.
If the server memory is 512M, the file size 160M can be uploaded. (haven't tried, csdn the unanimous opinion of the public posts. )
The setup of the Web. config is over here.
However, once the upload file size exceeds the file size range of this setting, the following error occurs: The page cannot display the page you want to view is currently unavailable. The site may be experiencing technical problems, or you will need to adjust your browser settings.
Although can not solve, that also want to catch this mistake Ah! What do we do? Because this error is a foreground error raised by the file control, it is not feasible to use Try...catch to capture in the background.
Then thought of using. NET error capture page mechanism to handle. Yes, it is possible.
The following is the referenced content:
1. Set up Web. config First
<customerrors mode= "on"/>
2, create a new error.aspx file, specifically used to catch the wrong.
3. Add page instructions to the foreground page of the ASPX page where the file is uploaded. Errorpage= "Uploaderror.aspx"
4. Add some code in error.aspx to determine if the error message is a foreground error caused by file.
public class UploadError:System.Web.UI.Page {private void Page_Load (object sender, System.EventArgs e) {Exception ex = Server.GetLastError (); if (ex! = null) {Response.Redirect (". /error.aspx "); The Else//foreground error ex is null {Response.Redirect ("uploadexcel.aspx?err=1");//re-jumps to the upload page, plus the Err parameter is to display the error message}}
5. Display error prompt.
public class Uploadexcel:System.Web.UI.Page {private void Page_Load (object sender, System.EventArgs e) {if (request["E RR "] = =" 1 ") {Page.registerstartupscript (" Budget "," <script language = javascript> alert "(' Upload file has failed! F Ile size is too large! ') </script> "); } } }