How to access httpRuntime section of web.config fr

2019-02-06 17:58发布

问题:

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 way to read it?

Thank you in advance.

回答1:

You can try something like

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

you can then get section.MaxRequestLength



回答2:

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.