开发者

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

开发者 https://www.devze.com 2023-03-02 21:42 出处:网络
I am playing around with plupload and I made a huge file that is 80mb and开发者_Python百科 I am trying to upload it.

I am playing around with plupload and I made a huge file that is 80mb and开发者_Python百科 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消