We help IT Professionals succeed at work.
Get Started

BinaryWrite over SSL not working in IE

Last Modified: 2012-06-27
I am trying to have a page that offers a logged in user a text document for download. The text documents are in a password protected folder so the page would log in with the appropriate user to access the folder and then uses a binarywrite to serve up the text document. My code works perfectly in IE in a non secure environment but when I try to do it over SSL, I get the following error when I try to download the text document.

"Internet exlporer cannot download download.asp from secure.pageconcepts.com.

Internet explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."

It also seems to work in netscape. I really need to be able to offer password protected documents to logged in users so any help would be very much appreciated.

Here is the code I am using:

dim oSecurity
Set oSecurity = Server.CreateObject("SoftArtisans.FileManager")
oSecurity.LogonUser "XXXXXXX", "username", "password"


Dim      objStream
Dim      strDownloadFilename
Dim                strFile
dim                homeDirectory
Dim                strFileType
Dim                contentType

homeDirectory = "theDirectory"

Response.Buffer = True
Dim strFilePath, strFileSize, strFileName

Const adTypeBinary = 1

strFile = Request.QueryString("file")
strDownloadFilename = Request.QueryString("file")

' get full path of specified file
strFilePath = "C:\inetpub\wwwroot\" &  homeDirectory & "\MoM\" & strFile
strFileName = strDownloadFilename


Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

strFileType = lcase(Right(strFileName, 4))

' Feel Free to Add Your Own Content-Types Here
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"
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

Response.BinaryWrite objStream.Read

Set objStream = Nothing
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE