By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,636 Members | 1,814 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,636 IT Pros & Developers. It's quick & easy.

HttpRuntimeConfig MaxRequestLength

P: n/a
Does anyone know how to obtain the MaxRequestLength easily?

I have found that if you do the following;

object getCon = HttpContext.GetAppConfig("system.web/httpRuntime")

Then look at getCon in debug, you can see the HttpRuntimeConfig object
with the MaxRequestLength in it, but you cannot cast the object to
HttpRuntimeConfig, so cannot programmatically get at the
MaxRequestLength property.

Anyone have a clue about this?

I'm using .NET 1.1 and C#

I'm starting to think that opening the machine.config and parsing the
XML is going to be the only way, however I also will need a way of
querying .NET to get the path to machine.config to avoid hardcoding it.

Apr 23 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Figured it out...

Int32 maxRequestLength = 0;
object untypedHttpRuntime =
System.Configuration.ConfigurationSettings.GetConf ig("system.web/
if (untypedHttpRuntime != null)
Type type = untypedHttpRuntime.GetType();
FieldInfo maxRequestLengthField = type.GetField("_maxRequestLength",
(BindingFlags.Instance | BindingFlags.Public |
if (maxRequestLengthField != null)
object result = maxRequestLengthField.GetValue(untypedHttpRuntime) ;
if (result != null)
maxRequestLength = Convert.ToInt32(result);

Apr 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.