GetSection vs GetConfig

I’m in the process of writing an HttpModule in ASP.NET 2.0 / Whidbey
and have run into a problem when trying to get the maximum HTTP upload
limit. The following code works great in ASP.NET 1.1, but in 2.0 the
call to get the property returns null. I have tried using both
GetConfig (now obsolete in ASP.NET 2.0) and GetSection methods.

private int MaxRequestLength(HttpContext context)
// Load the httpruntime section from the config file.
object section = context.GetConfig(“system.web/httpRuntime”);
Type configSection = section.GetType();
if (null != configSection)
// Use reflection to get the MaxRequestLength property from the section.
PropertyInfo pInfo = configSection.GetProperty(“maxRequestLength”, BindingFlags.Instance | BindingFlags.NonPublic);
if (null != pInfo)
return (int)pInfo.GetValue(section, null);
return -1;

Can anyone help?

One thought on “GetSection vs GetConfig

Comments are closed.