File upload size limit 10MB

Discussion in 'ASP.NET / ASP.NET Core' started by pclcodesnet, Aug 10, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I read that you can override this to allow larger files by editing my application's web.config file.

    How is this accomplished and does anyone have an examples or code?

    Thanks, :)

    Brad
     
  2. Maximum request length exceeded

    Now that I have it set where I want it how do I capture the "Maximum request length exceeded" errors and tell the user that their file is over the 20 MB limit?
     
  3. lazycoder

    lazycoder Guest

    Unfortunately, when the request length exceeds the limit, your application isn't notified. Instead, IIS aborts the request.

    The best you can do is to have the upload form in an iframe, then set up a javascript timer on container page which will periodically check for readyState=='complete' of the document in the iframe, and check the title of that document. If the upload worked, the document's title should be whatever you set it in TITLE tag of returned success page. If upload fails, the check of readyState throws an error or the title is wrong, depending on browser.

    That javascript function may look something like this:

    function monitor_upload() {
    var error;
    var iframe = document.getElementById('iframeID');
    var doc = (iframe.contentDocument ? iframe.contentDocument : iframe.contentWindow.document)
    try {
    if (doc.readyState == 'complete' && iframe.title != 'Your Expected Title')
    error = 1;
    }
    catch (err) {
    error = 1;
    }
    if (error) {
    alert("Maximum request length exceeded.");
    }
    else
    setTimeout("monitor_upload()", 250);
    }

    then call monitor_upload(); when submit button is clicked.


    Hope it helps.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page