Warning: Creating default object from empty value in /homepages/42/d301471907/htdocs/wp-includes/functions.php on line 334
C l e a r G l a s s ~ Blog
CG Rotating Images

Welcome to C l e a r G l a s s

Problem with ADODB.Stream and large files

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/42/d301471907/htdocs/wp-includes/functions-formatting.php on line 76

I was working on a system that will force a prompt to save when downloading files using a web browser. I ran into a problem with downloading larger files. An easy fix is to increase the AspBufferingLimit in Metabase.xml.

ASP Code:

Response.Buffer = True
Dim Path, file, strFilePath, strFileSize, strFileName, objStream, strFileType, ContentType
Path = Request("Path")
File = Request("File")
Const adTypeBinary = 1
strFilePath = Server.MapPath(Path) & “” & file
strFileName = file
strFileType = lcase(Right(strFileName, 4))
Select Case strFileType
 Case “.asf”
  ContentType = “video/x-ms-asf”
 Case “.avi”
  ContentType = “video/avi”
 Case “.doc”
   ContentType = “application/msword”
 Case “.zip”
  ContentType = “application/zip”
 Case “.xls”
  ContentType = “application/vnd.ms-excel”
 Case “.gif”
  ContentType = “image/gif”
 Case “.jpg", “jpeg”
  ContentType = “image/jpeg”
 Case “.wav”
  ContentType = “audio/wav”
 Case “.mp3″
  ContentType = “audio/mpeg3″
 Case “.mpg", “mpeg", “mpga”
  ContentType = “video/mpeg”
 Case “.rtf”
  ContentType = “application/rtf”
 Case “.htm", “html”
  ContentType = “text/html”
 Case “.asp”
  ContentType = “text/asp”
 Case Else
  ’Handle All Other Files
  ContentType = “application/octet-stream”
End Select
Response.AddHeader “Content-Disposition", “attachment; filename=” & strFileName
Response.AddHeader “Content-Length", strFileSize
Response.Charset = “UTF-8″
Response.ContentType = ContentType
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
Set objStream = Nothing

Error Message:

Response object error 'ASP 0251 : 80004005'
Response Buffer Limit Exceeded
/download.asp, line 0
Execution of the ASP page caused the Response Buffer to exceed its
configured limit.


If you get the above error when you click on an attachment, the attachment is larger than IIS is configured to allow. Change the AspBufferingLimit setting in Metabase.xml to a larger size. The default value is 4194304, which is about 4 MB. Change this to whatever limit is reasonable for the types of files your users will be attaching.

This change does not require stopping IIS, but to make the Metabase.xml file write-able, you need to go to the IIS control panel, right click the server, select properties, and check off the box that says “allow changes to MetaBase configuration while IIS is running".


Xefteri - Downloading any file using ASP…
FogBugz - IIS 6: Cannot open attachment…
WindowsDevCenter.com - Inside the XML Metabase of IIS 6

— admin @ 10:49 am 7/25/2005

ClearGlass LLC © 2009-2011. All rights reserved.