Results 1 to 2 of 2

Thread: maxRequestLength not friendly error message and crop image

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    maxRequestLength not friendly error message and crop image

    I set the maxRequestLength ="1024" in my web.config, so everytime the user upload file more than 1MB, it doesn't present any errors, but just display page cannot be displayed. Is there a way to present a message rather than the IE message?

    also, how to determine the size of the image when the users upload the image file and crop it?

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: maxRequestLength not friendly error message and crop image

    Internet Explorer, by default, displays a "friendly" error message when it receives an error status code from the server. For development purposes, you may find it best to disable this feature, or use another browser. The option is available at: Tools > Internet Options > Advanced > "Browsing" section > "Show friendly HTTP error messages".

    As you've discovered, setting the maximum request length instructs the ASP.NET runtime to prevent any incoming requests that exceed that length from being processed. According to the docs, this would be useful in preventing denial of service attacks that are predicated on large files. There is no way to determine the size of a file, using the HTML standards before it has been uploaded to the server.

    Given all that blather and in order to gain more granular control, I would suggest:
    1) Use the Global.asax file to catch unhandled exceptions. When the file exceeds the max, a HttpException will be thrown. I'll leave it as an exercise to the reader to figure out how to catch exceptions.
    2) Add an extra check within your code to prevent (and/or delete) uploaded files that exceed the maximum.
    3) See if you can introduce disk quotas to prevent absolute hell breaking loose.
    4) Should you be cropping, or perhaps resizing?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width