473,394 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Working with BinaryWrite

From a client, I call

http://server/retrieve.aspx?guid=somevalue

Then, in page_load of retrieve.aspx I have

filespec = "test.mdb"
pathspec = "c:\"

MyFileStream = New FileStream(pathspec & filespec, FileMode.Open)
FileSize = MyFileStream.Length

Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()

Response.BufferOutput = True
Response.ContentType = "application/asp-unknown"
Response.AddHeader("content-disposition", "attachment; filename=" &
filespec)
Response.BinaryWrite(Buffer)
Response.Flush()
But if I have the above http link in an email message for example, the file
downloads just fine with the Save As dialog, but back in the browser, it
displays:

Action canceled
Internet Explorer was unable to link to the Web page you requested.
The page might be temporarily unavailable.
How can I place a meaningful message in the browser, or redirect?
Response.Redirect or Server.Transfer are ignored after the Flush. Any
ideas?

Jeff
Nov 18 '05 #1
1 1038
Hello Jeff,

After Response.Flush, try Response.End(). My guess is you're getting further
into the Page processing than you want to.

When I do things like this, I typically implement them as an HttpHandler,
however, that's beyond the scope of your question. :=)

--
Matt Berther
http://www.mattberther.com
From a client, I call

http://server/retrieve.aspx?guid=somevalue

Then, in page_load of retrieve.aspx I have

filespec = "test.mdb"
pathspec = "c:\"
MyFileStream = New FileStream(pathspec & filespec, FileMode.Open)
FileSize = MyFileStream.Length

Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()
Response.BufferOutput = True
Response.ContentType = "application/asp-unknown"
Response.AddHeader("content-disposition", "attachment; filename=" &
filespec)
Response.BinaryWrite(Buffer)
Response.Flush()
But if I have the above http link in an email message for example, the
file downloads just fine with the Save As dialog, but back in the
browser, it displays:

Action canceled
Internet Explorer was unable to link to the Web page you
requested.
The page might be temporarily unavailable.
How can I place a meaningful message in the browser, or redirect?
Response.Redirect or Server.Transfer are ignored after the Flush. Any
ideas?

Jeff

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jens S0nderby Munk | last post by:
Hi, I'm having some problems with the Reponse.BinaryWrite, IE 6.0 and Adobe Reader 6.0. When I try to write a pdf-file to an IE browser with a Adobe Reader 6.0 installed then it just displays a...
1
by: Kevin Humphreys | last post by:
Hi All, Please help me regarding the 'Response.BinaryWrite' I am making one web application where I need to store some of client logo's and others images. In this context I am able to store...
6
by: James | last post by:
when i right click and try to save a picture from my web site it some times defaults the name and file type to 'unknown' bmp. the file is really a jpeg that i am using the .binarywrite to display...
0
by: B_O_B | last post by:
I am using Response.BinaryWrite to display JPEG's to the browser. The problem is that in IE, one particular JPEG is loading very slow. Normal JPEG's take a few seconds, but this one sometimes...
2
by: Nik | last post by:
I am trying to write out the equivalent of this asp statement in c#: Response.BinaryWrite(chrb(239) & chrb(187) & chrb(191)) 'BOM = EF BB BF string binString = "11111111"; byte myBin =...
2
by: Vinay | last post by:
Hi All: I have a frameset (right and left). In the left frame I have a listbox that contains items. When the user clicks on any one of these items (each item points to either a word document or...
11
by: Random | last post by:
I have tried all the Response methods I can think of (WriteFile, BinaryWrite, OutputStream) to write the byte array of a pdf file to the response. The result looks like it's trying, it comes up as...
1
by: mattridings | last post by:
Hi gang, Have a script that works fine. However, it's really cpu intensive and I'm looking for suggestions on a) whether or not that's normal and if so b)a better way of doing it. Script is...
14
by: S N | last post by:
I am using the following code to hide the download url of files on my website. The code uses Response.Binarywrite to send file to the client. Kindly indicate the maximum size of the file that can be...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.