Heinz
Heinz

Reputation: 115

Accessing httpRuntime maxRequestLength programmatically

I've looked around and have yet found a way to sync between the config section for file size and the max I am allowing. Is it even possible?

Is it just best practice to allow very large file sizes in the web.config file and then enforce smaller sizes in your implementations?

Upvotes: 4

Views: 2515

Answers (1)

Adrian
Adrian

Reputation: 691

Try something like this:

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

So then you get section.MaxRequestLength

Upvotes: 1

Related Questions