How to catch ConfigurationErrorsException for violating maxRequestLength?

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

       catch (Exception ex)
       {
           if (ex is HttpException && (ex as HttpException).WebEventCode == 3004)
           {
                //-- you can now inform the client that file uploaded was too large.
           }
           else
               throw;
       }
    

提交回复
热议问题