Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 915
Tim Schmelter Avatar asked Feb 03 '11 13:02

Tim Schmelter


People also ask

What is the appSettings section in the Web config file?

The <appSettings> element of a web. config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work.

What is MaxRequestLength in web config?

The MaxRequestLength property specifies the limit for the buffering threshold of the input stream. For example, this limit can be used to prevent denial of service attacks that are caused by users who post large files to the server.


1 Answers

You can try something like

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

you can then get section.MaxRequestLength

like image 185
V4Vendetta Avatar answered Oct 01 '22 09:10

V4Vendetta