Response.BinaryWrite

L

Laurahn

Hi:

I'm dealing with a file type when i convert it from a BLOB field on database and i use the Response.BinaryWrite method. The file type is *.chm. That's my code:

Private Sub ReadFile(ByVal MyData() as Byte)
If Not MyData Is System.DBNull.Value then
Response.Buffer = True
Response.ContentType ="application/octet-stream"
Response.BinaryWrite(MyData)
End If
End Sub


When i retrieve different type of file "Response.ContentType = "application/msword"" the code works fine. I can see the file on the IE or download the file to disk.

Can someone tell me, how can i retrieve *.chm files from database to end user. I want to make a simple download of the file.
 
J

Juan T. Llibre

See Rick Strahl's recommendations at :

http://www.west-wind.com/WebLog/posts/2928.aspx

Bottom line : don't try to stream chm files directly for client usage.
Always have them downloaded to the client and let the client open them later.




Hi:

I'm dealing with a file type when i convert it from a BLOB field on database and i use the
Response.BinaryWrite method. The file type is *.chm. That's my code:

Private Sub ReadFile(ByVal MyData() as Byte)
If Not MyData Is System.DBNull.Value then
Response.Buffer = True
Response.ContentType ="application/octet-stream"
Response.BinaryWrite(MyData)
End If
End Sub


When i retrieve different type of file "Response.ContentType = "application/msword"" the code works
fine. I can see the file on the IE or download the file to disk.

Can someone tell me, how can i retrieve *.chm files from database to end user. I want to make a
simple download of the file.
 
L

Laurahn

I got the answer:

Is needed to use a diferent parameter for download a *.chm file:

Response.AddHeader("Content-Disposition", "attachment;filename=MyFile.chm")
 
W

Walter Wang [MSFT]

Hi Laurahn,

I just saw your post and I'm glad you've found the solution. For your
reference, here's a KB might be useful for you:

#HOW TO: Read and Write BLOB Data by Using ADO.NET Through ASP.NET
http://support.microsoft.com/kb/326502

This KB describes a similar scenario like yours.

Please feel free to reply here if there's anything else I can help.

Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top