By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,636 Members | 1,693 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,636 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.