简体   繁体   中英

How to get an error back when file limit is reached? Plupload + asp.net mvc 3 + web.config

I am playing around with plupload and I made a huge file that is 80mb and I am trying to upload it.

plupload looks like it is uploading it. It starts at 0% and goes to 100%.

Now it dies at the server and the reason is because the default limit size is like 4mbs in the web.config controlled by this

<httpRuntime executionTimeout="240" maxRequestLength="102400" />

When I set it to a high number like above the file uploads and I hits my break point. If I don't have the above set and upload a large file(over 4mb) It never hit's my break point in my action method.

So how can I tell my users that hey they reached the limit? If I can't get into my methods and at the very least return a message back. Right now they would think that all was well and it uploaded.

I know plupload does have stuff that checks the file size but I treat that like client side validation and now I am trying to do server side validation.

 [HttpPost]
        public JsonResult Import(HttpPostedFileBase file)
        {
            // never gets here if file is bigger than the web.config size.
            if (ModelState.IsValid)
            {

            }

        }

You may take a look at the following blog post which suggests handling this exception in the Application_Error method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM