0

Another question from me. This wont be an easy one!

I'm having issues with handling a simple upload. Pre Requirements to test with: - No Flash (hijacking) - Basic upload field usage + form to post - Max file size is 20MB (web.config maxrequestlength) - I'm running the web site with the build in IIS development tool in visual studio (i think) - I'm using a MVC web project

Question: Is it possible to show a nice error message to the user when a file is larger than 20MB? (Without getting the whole file to the server first)

These links helped me the most:

http://www.telerik.com/community/forums/aspnet/upload/maximum-request-length-exceeded.aspx

ASP.NET MVC: Handling upload exceeding maxRequestLength

http://forums.whirlpool.net.au/archive/809909

http://forums.asp.net/t/1106579.aspx/1

Catching "Maximum request length exceeded"

But still i haven't been able to fix the issue. Atm i use the code of the accepted answer of the last link (Catching "Maximum request length exceeded"), but my code crashes when i run the code line below:

this.Server.Transfer("~/error/UploadTooLarge.aspx");

Error message: Error executing child request for ~/error/UploadTooLarge.aspx.

I think i get this message because i'm using VS.NET's build in web server (see: http://forums.asp.net/t/1106579.aspx/1 last post of that page).

I'm affraid i made the whole question a bit hard to read. In short: How can i show a neat error message when i uploaded file is too large (using S.NET's build in web server)?

Community
  • 1
  • 1
PcPulsar
  • 444
  • 6
  • 18

1 Answers1

0

If you don't want to send to whole file to the server first, then your only option would be javascript. The FileReader object would solve that for you https://developer.mozilla.org/en-US/docs/DOM/FileReader Problem being it won't work on older browsers. Now, if older browsers are not a problem for you then you should find plenty of tutorials showing you how to use the FileReader object. With it you can do asynchronous uploads so you even add a nice progress bar considering is fairly large file.

coffeeyesplease
  • 1,018
  • 9
  • 15