For retrieving maxrequest length from web.config use following function:
public int GetMaxLength()
{
HttpRuntimeSection httpRuntime =
(HttpRuntimeSection)ConfigurationManager.GetSection("system.web/httpRuntime");
return httpRuntime.MaxRequestLength;
}