Asp.net File Upload Error Handling
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Asp.net Error Page
and policies of this site About Us Learn more about Stack Overflow asp.net mvc error handling the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags asp.net error logging Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only http://forums.asp.net/t/2006467.aspx?Large+File+Size+Upload+Error+Handling takes a minute: Sign up Catch upload of to big files up vote 3 down vote favorite 1 Asp.Net has an upper limit for file uploads. I try to catch this situation on the server side. According to the documentation I found, it should be possible to override Application_Error in Global.asax, but it does not work for me. The second http://stackoverflow.com/questions/1808047/catch-upload-of-to-big-files option would be to override OnError of the receiving page, but that also does not work. Can anybody show some working code on how to catch this error on the server side? asp.net error-handling file-upload share|improve this question edited Feb 27 '13 at 22:04 John Saunders 138k20175319 asked Nov 27 '09 at 10:50 Achim 8,40943986 add a comment| 5 Answers 5 active oldest votes up vote 2 down vote Put following in Golobal.asax.cs: void Application_Error(Object sender, EventArgs e) { HttpException ex = Server.GetLastError() as HttpException; if (ex != null) { if ((ex.GetHttpCode() == 500 || ex.GetHttpCode() == 400) && ex.ErrorCode == -2147467259) { Server.ClearError(); Response.Redirect("~/MaximumFileError.aspx", false); } } } This worked for me, but I'm not sure if it works for all cases. share|improve this answer answered Jan 8 '10 at 20:24 Sasapet 412 add a comment| up vote 1 down vote Uploadify is a jquery and flash uploader that allows you to specify a max size for files to be downloaded. This way you can prevent the user from downloading the file in the first place and dont hav
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more http://stackoverflow.com/questions/126167/asp-net-how-to-show-a-error-page-when-uploading-big-file-maximum-request-leng about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ASP.NET - how to show a error page when uploading big file (Maximum request length exceeded)? up vote 12 down vote favorite 2 Application able to record error error handling in OnError, but we are not able to do any redirect or so to show something meaningfull to user. Any ideas? I know that we can set maxRequestLength in web.config, but anyway user can exceed this limit and some normal error need to be displayed. .net asp.net file-upload maxrequestlength application-onerror share|improve this question edited Apr 10 '09 at 13:41 JohnIdol 23.3k43125218 asked Sep 24 '08 at 9:15 st78 3,52353556 add a comment| 6 Answers 6 active oldest file upload error votes up vote 6 down vote accepted As you say you can setup maxRequestLength in your web.config (overriding the default 4MB of your machine.config) and if this limits is exceeded you usually get a HTTP 401.1 error. In order to handle a generic HTTP error at application level you can setup a CustomError section in your web.config within the system.web section: