How to catch ConfigurationErrorsException for violating maxRequestLength?

后端 未结 5 1572
[愿得一人]
[愿得一人] 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:00

    There is no way to do it right without a client-side help. You cannot determine if the request is too long unless you read all of it. If you read each request to the end, anyone come and keep your server busy. If you just look at content length and drop the request, other side is going to think there is a connection problem. It's nothing you can do with error handling, it's a shortcoming of HTTP.

    You can use Flash or Javascript components to make it right because this thing can't fail nicely.

提交回复
热议问题