Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm new to this forum so not sure if this is the correct place to put this question. So if it isn't, please point me to the correct place to post it.
I am having an issue with large file upload. I keep getting the YSOD (Yellow Screen Of Death) with the message "Maximum request length exceeded". I know I can increase the maxRequestLength in web.config to handle bigger file size. I also know the trick to increase maxAllowedContentLength (if needed to be) on IIS7. HOWEVER, I do not want to keep on increasing the limit. I want to handle the exception myself.
All the page I had found so far with google relating this is to do it in global.ascx (Application_Error). Since I don't have access to that file on Umbraco, how can I do it? Is there a way of doing this already on Umbraco that I'm unaware of?
You need to modify the maxRequestLength in the httpRuntime tag in the web.config to allow larger files.
Change it to something like this:
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
my bad.. sometimes I respond before i finish ready the entire post... hmm
Instead of using the global.asax file you can use a HTTPHandler
Could you please elaborate that a bit? I have never use a HTTPHandler to catch an exception before and don't really understand the logic here.
Here's some documentation on the subject: http://msdn.microsoft.com/en-us/library/bb398986.aspx
Create a class and implement the IHttpModule interface.
You need to register the handler using 1 of 2 ways:
You need to reference Microsoft.Web.Infrastructure.dll for the second method. (Details here: http://odetocode.com/blogs/scott/archive/2011/02/27/dynamicmoduleutility.aspx)
You can set the request lenght to something like 1GB and the timeout to 1 hour (although I know you don't want to).
BUT also use a client upload tool (like ajaxuploader) that checks the file size on the client's computer before even trying to upload, so your webserver resources don't get tied up.
An example of an error logging HTTPModule (with log4net): http://codebetter.com/karlseguin/2006/06/12/global-asax-use-httpmodules-instead/
An implementation of an HttpModule to handle the MaxRequestLength error can be found here:
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted