How to catch ConfigurationErrorsException for violating maxRequestLength?

后端 未结 5 1629
[愿得一人]
[愿得一人] 2020-12-15 10:26

I am limiting file size users can upload to the site from Web.config. As explained here, it should throw a ConfigurationErrorsException if size is not accepted. I tried to c

5条回答
  •  我在风中等你
    2020-12-15 11:07

    I am not 100% on this, but I think it might help if you tried changing:

    context.Response.Redirect(this.Request.Url.LocalPath + "?action=exception");

    to

    Server.Transfer(this.Request.Url.LocalPath + "?action=exception,false)

    My thinking is that the the over-max-request-length Request is still being processed in the Redirect call but if you tell it to ditch the form data, it will become under the max request length and then it might behave differently.

    No guarantees, but its easy to check.

提交回复
热议问题