Ron wrote on Wed, 19 Nov 2008 13:07:33 -0800:
Quote:
I'm getting this in an ASP application on IIS6/W2K3. The page in
question is trying to return a XML file approximately 45MB in size.
Changing this is not an option. Worked fine on IIS5/W2K. I tried
Response.Buffer = False, no joy. So I searched on MSDN and found
instructions for increasing the AspBufferingLimit property in the
metabase. I increased it to 100MB for
that web application, stopped and restarted that web application,
still same result.
|
Quote:
I ran into a similar problem on the same web app in two pages where we
are trying to receive a file of approx. 10MB in size. I was told to
set the AspMaxRequestEntityAllowed property in the metabase for the
specific
pages. I set it to 16MB for each - they still don't work, either. How can
I
make my legacy app work in IIS6?
|
I wouldn't go messing with the settings - instead, chunk out the XML file in
small pieces. If this XML is coming from a file then you could use an ADO
Stream object to do this quite simply. Even turning off the buffering
doesn't help if you try to send a large file all in one go.
AspMaxRequestEntityAllowed is for incoming data to the server, not for
outgoing data - the clue is in the property name which contains the word
Request. The value you would need to change is AspBufferLimit, eg.
cscript.exe adsutil.vbs SET w3svc/aspbufferinglimit 104857600
will increase the limit to 100MB. However, I would strongly recommend
against this as it makes your application reliant on that setting. What
happens when you want to push out a 250MB file, or a 500MB, or even bigger.
Instead of adjusting that to suit your app, make your app send the file out
in pieces.
Here's some code that works on my site:
Set oStream = Server.CreateObject("ADODB.Stream")
Call oStream.Open()
oStream.Type = 1
call oStream.LoadFromFile(strDir & strFilename)
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "filename=" &
strFilename & ";"
Response.AddHeader "Content-Length", oStream.Size
Response.Buffer = False
'stream out the file in chunks
Do While Not (oStream.EOS)
Response.BinaryWrite oStream.Read(1024 * 256)
Loop
oStream.Close
Set oStream = Nothing
Response.End
strDir and strFilename are variables holding the directory and the filename
that is to be sent respectively.
This sets the ContentType and filename in the headers, and it's total length
so that the browser download dialog can show the user a progress percentage
if supported. Buffering is then turned off (it's on by default for the
server and this site too). It then reads 256kB at a time and sends it to the
browser - sending in small chunks with buffering off automatically clears
the buffer after each BinaryWrite call. So far it's worked well on all the
files I've delivered from my application, although they have been reasonably
small (up to around 35MB) but with the default 4MB limit of IIS6.
--
Dan