473,382 Members | 1,441 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,382 software developers and data experts.

how do I get the value of httpruntime.maxRequestLength through code?

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. However how do
I check the maxRequestLength value through code?

Let me set a bit of background. I don't actually have any ASPX pages I have
a DLL written in VB.NET that has various classes, one implements
IHttpHandlerFactory
and the GetHandler function.

If a file is uploaded that is greater than the max size defined then
immediately after the GetHandler
function ends execution stops and the browser displays a "page unavailable"
message. Therefore
what I was planing to do was loop through the Request.Files collection in
the current httpcontext
and destory any file whose contentlength\1024 was > maxRequestLength.

However System.Web.HttpRuntime does not expose this property so how do I get
the value?

Regards,
Peter
Nov 18 '05 #1
2 7934
Hi,

Hmmm... I'd still like to know how you get the maxRequestLength through
code, but a little test shows
that when an uploaded file exceeds the size limit then
httpContext.Request.Files.Count = 0 (in the example
of uploading only 1 file) and as described the GetHandler function finishes
but returns a "page unavailable"
message to the browser, so not sure how I'm suppose to trap this.

Anybody have any ideas.

Regards,
Peter
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:uf**************@TK2MSFTNGP12.phx.gbl...
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. However how do
I check the maxRequestLength value through code?

Let me set a bit of background. I don't actually have any ASPX pages I have a DLL written in VB.NET that has various classes, one implements
IHttpHandlerFactory
and the GetHandler function.

If a file is uploaded that is greater than the max size defined then
immediately after the GetHandler
function ends execution stops and the browser displays a "page unavailable" message. Therefore
what I was planing to do was loop through the Request.Files collection in
the current httpcontext
and destory any file whose contentlength\1024 was > maxRequestLength.

However System.Web.HttpRuntime does not expose this property so how do I get the value?

Regards,
Peter

Nov 18 '05 #2
Hi,

Hmmm... I'd still like to know how you get the maxRequestLength through
code, but a little test shows
that when an uploaded file exceeds the size limit then
httpContext.Request.Files.Count = 0 (in the example
of uploading only 1 file) and as described the GetHandler function finishes
but returns a "page unavailable"
message to the browser, so not sure how I'm suppose to trap this.

Anybody have any ideas.

Regards,
Peter
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:uf**************@TK2MSFTNGP12.phx.gbl...
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. However how do
I check the maxRequestLength value through code?

Let me set a bit of background. I don't actually have any ASPX pages I have a DLL written in VB.NET that has various classes, one implements
IHttpHandlerFactory
and the GetHandler function.

If a file is uploaded that is greater than the max size defined then
immediately after the GetHandler
function ends execution stops and the browser displays a "page unavailable" message. Therefore
what I was planing to do was loop through the Request.Files collection in
the current httpcontext
and destory any file whose contentlength\1024 was > maxRequestLength.

However System.Web.HttpRuntime does not expose this property so how do I get the value?

Regards,
Peter

Nov 18 '05 #3

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

Similar topics

2
by: James Geurts | last post by:
Hi, I am not able to find information on this elsewhere... Is there a way to get the HttpContext attribute maxRequestLength's value programmatically? I know I could load the web.config file as a...
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.
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...
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...
5
by: Matt Chubb | last post by:
I've searched the forums and the net and have not found a solution to this upload problem, any suggestions/help in this matter would be greatly appreciated. I'm trying to trap and display an...
2
by: Anuradha | last post by:
Hi all, I had my web.config file as below... <system.web> <httpRuntime executionTimeout="90" maxRequestLength="102400" useFullyQualifiedRedirectUrl="false" minFreeThreads="8"...
1
by: Andy Stephens | last post by:
Hi all I'm developing a site where visitors can upload images (using the html file input control). As most webhosting companies set a monthly bandwidth limit I want to try and limit the size of...
6
by: =?Utf-8?B?emlubw==?= | last post by:
in asp.net 2, I load a dataset from the Cache object into a local object to use to perform processing. I had been using httpcontext.current.cache and what I noticed is sometime I'm not able to get...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.