How to access httpRuntime section of web.config from codebehind?

后端 未结 2 1771
攒了一身酷
攒了一身酷 2020-12-31 13:33

actually i need the maxRequestLength value of the httpRuntime section in web.config to check if a postedfile\'s size is greater. What\'s the best w

相关标签:
2条回答
  • 2020-12-31 14:02

    On load of your page set the max file size to a client side variable and check it on a client event because if you request the server to check it obviously it will error out before it gets to your validation.

    0 讨论(0)
  • 2020-12-31 14:07

    You can try something like

    HttpRuntimeSection section = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection;
    

    you can then get section.MaxRequestLength

    0 讨论(0)
提交回复
热议问题