GetSection vs GetConfig: Solution

Okay, after faffing around for a couple of hours on Google and
experimenting with the new Configuration Management API I managed to
find a solution to my earlier problem. The following code demonstrates
the new way of retrieving the maximum HTTP request size from the
web.config file.

private int MaxRequestLength(HttpContext context)
int result = -1;
// Load the HttpRuntime section from the config file.
Configuration config = WebConfigurationManager.OpenWebConfiguration(“~”);
if (null != config)
HttpRuntimeSection section = config.GetSection(“system.web/httpRuntime”) as HttpRuntimeSection;
// Get the MaxRequestLength property from the section.
if (null != section)
result = section.MaxRequestLength;
return result;