How to access httpRuntime section of web.config fr

2019-02-06 16:59发布

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.

2条回答
Luminary・发光体
2楼-- · 2019-02-06 17:44

You can try something like

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

you can then get section.MaxRequestLength

查看更多
啃猪蹄的小仙女
3楼-- · 2019-02-06 17:46

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.

查看更多
登录 后发表回答