Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ken Thai 10 posts 30 karma points
    Mar 31, 2011 @ 01:15
    Ken Thai
    0

    Handling exception Maximum request length exceeded

    Hi,

    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?

     

  • Daniel Bardi 927 posts 2562 karma points
    Mar 31, 2011 @ 01:45
    Daniel Bardi
    0

    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" />
  • Daniel Bardi 927 posts 2562 karma points
    Mar 31, 2011 @ 01:47
    Daniel Bardi
    0

    my bad.. sometimes I respond before i finish ready the entire post... hmm

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Mar 31, 2011 @ 06:32
    Richard Soeteman
    0

    Instead of using the global.asax file you can use a HTTPHandler

    Cheers,

    Richard

  • Ken Thai 10 posts 30 karma points
    Apr 01, 2011 @ 01:02
    Ken Thai
    0

    Hi Richard,

    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.

    Regards,

    Ken

  • Daniel Bardi 927 posts 2562 karma points
    Apr 01, 2011 @ 01:50
    Daniel Bardi
    0

    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:

    • 1. In the web.config httpModules section
    • 2. Dynamically in code using PreApplicationStartMethod with DynamicModuleUtility.RegisterModule() in a class inherited from ApplicationBase

    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)



  • David Verberckmoes 46 posts 77 karma points
    Apr 01, 2011 @ 13:28
    David Verberckmoes
    0

    Hi,

    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/

     

    Rgds,

    David#

  • John Ligtenberg 53 posts 214 karma points
    Nov 26, 2012 @ 17:25
    John Ligtenberg
    0

    Hi,

    An implementation of an HttpModule to handle the MaxRequestLength error can be found here:

    http://our.umbraco.org/forum/core/general/6704-How-to-implement-custom-error-page-after-exceeding-httpRuntime-maxRequestLength

    Regards,

    John

     

     

Please Sign in or register to post replies

Write your reply to:

Draft