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

P

Peter Row

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
 
P

Peter Row

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top