asp.netrazorwebmatrix-2

Displaying an error message for System.Web.HttpException: Maximum request length exceeded in WebMatrix


I have tried to catch my HttpExceptions using a try catch block in my *_PageStart.cshtml* file using this site as a reference but that didn't seem to work. Does anyone else have a solution for setting a max filesize error message? I do not wish to simply increase my upload limit in web.config because users of my site shouldn't need to be uploading files larger than 10MB, so that is my upload limit. I have also tried handling it with my global.asax file but that didn't work.

Surely, there must be a way to redirect to another page or to simply display an error message upon receiving a file which exceeds the request limit.


Solution

  • I have managed to fix this myself by using the event handler in Global.asax