Display custom error page when file upload exceeds allowed size in ASP.NET MVC

后端 未结 4 1136
鱼传尺愫
鱼传尺愫 2020-11-28 23:06

My main issue is that I want to display an custom error page when an uploaded file exceeds allowed size (maxRequestLength in web.config).

When the big file is upload

4条回答
  •  春和景丽
    2020-11-28 23:55

    When running on IIS6, I solved it with a HttpModule by handling the BeginRequest and check if httpApplication.Context.Request.Length is larger than maxRequestLength.

    To be able to redirect the entire request has to be read before redirecting.

    See code example at this link: http://www.velocityreviews.com/forums/t97027-how-to-handle-maximum-request-length-exceeded-exception.html

提交回复
热议问题