473,327 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

HttpRuntimeConfig MaxRequestLength

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
1 2394
Figured it out...

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

Apr 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brad | last post by:
I'd like to display the maxRequestLength value on a page, so users could see what the aprox current file upload size limit is. Can the value of maxRequestLength be determined at runtime? Can it...
2
by: Peter Row | last post by:
Hi, To allow users to upload files larger than 4MB in size I added: <httpRuntime maxRequestLength="102400" executionTimeout="600" /> ...to my web.config file. Fair enough this works fine....
25
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
1
by: toto | last post by:
Example: <configuration> <system.web> <httpRuntime maxRequestLength="2048" /> </system.web> </configuration> I need to kno in my code the value of key maxRequestLength. Thanks in advance.
2
by: David | last post by:
Where and how can I set maxRequestLength?
2
by: Jay | last post by:
I have been trying to use maxRequestLength to stop users from uploading large files. It put this code in the web.config file: <httpRuntime maxRequestLength="128" /> --The upload works...
3
by: Stephen Ahn | last post by:
Given a web service method defined like this : public string EchoByteArray(byte data) { return data.Length.ToString() + " bytes received"; } If, from a Windows C# app, I call this web...
1
by: Joseph Geretz | last post by:
I've been using the following (client-side) configuration block to allow WSE/DIME transfer of files larger than 4 meg: <messaging> <maxRequestLength>-1</maxRequestLength> </messaging> (Of...
2
by: Joseph Geretz | last post by:
I'm developing a Web Service using DIME to download and upload files from and to an IIS server. In order to increase the download filesize to unlimited, I have the following block in my App.config...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.