473,491 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Response.BinaryWrite Not Returning Result

Hi all,

I have a web application that uploads a file into a SQL database as a stream
of bytes.

On another page of the app, I retrieve the same byte stream from SQL, and my
ultimate goal is for the user to see the "save" dialog so that they can
download it as a file on their own computer.

I'm using this C# code to return the result to the user:
Response.Clear();
Response.ContentType =
Convert.ToString(Session["DataContentType"]);
Response.AddHeader("Content-Disposition", "attachment;
filename=" +
Convert.ToString(Session["DataFileName"]));
Response.BinaryWrite(_ibuffer);

If I set a breakpoint in this code, I see that there is a web page in my
browser that is waiting for the code to complete. However, as soon as I
choose Continue in the debugger, the browser window closes, and there is no
dialog asking me to save the file.

Here's what I've tried:
- calling Response.ClearContent() and Response.ClearHeaders() in the
beginning
- putting in a call to Response.End() at the end
- changing "attachment" above to "inline"

The first 2 options gave the same result (the browser window closes). The
3rd option allowed me to view content for "known" file types such as JPG in
the browser, but for unknown file types, the browser window still closed.

Any ideas?

--
My BizTalk blog:
http://stevestechnotes.blogspot.com/
Mar 6 '08 #1
2 1815
I solved my own problem -- when I used "localhost" as the server name in the
browser URL, it behaves as below. When I replace it with the actual server
name, it works the way I want it to.

- Steve

"Steve Harclerode" <Li*************@hot.mail.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
Hi all,
browser that is waiting for the code to complete. However, as soon as I
choose Continue in the debugger, the browser window closes, and there is
no dialog asking me to save the file.

Mar 6 '08 #2
In case someone else runs into this problem:

I discovered that localhost was listed in the trusted servers. When I
removed it from the list, now I can use localhost in the URL. Why that would
cause a problem is beyond me, but there it is...

- Steve

"Steve Harclerode" <Li*************@hot.mail.comwrote in message
news:OG**************@TK2MSFTNGP05.phx.gbl...
>I solved my own problem -- when I used "localhost" as the server name in
the browser URL, it behaves as below. When I replace it with the actual
server name, it works the way I want it to.

- Steve

"Steve Harclerode" <Li*************@hot.mail.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
>Hi all,
browser that is waiting for the code to complete. However, as soon as I
choose Continue in the debugger, the browser window closes, and there is
no dialog asking me to save the file.


Mar 6 '08 #3

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

Similar topics

0
1809
by: Gunther Schmidl | last post by:
Hi, I've rolled my own perl component for resizing pictures on the fly, but I have a problem with actually outputting the resized image. Here's my code: Dim res Response.Buffer = true Set...
2
7169
by: Zam | last post by:
Hello World, Under Windows 2003 Server. IIS6. The following code working fine for small files, and for files with size about few megabytes. If I am trying to send HUGE file -- about 700...
2
2027
by: ATS | last post by:
HOWTO Override ASP's Response output for 2003/IIS. Please help, I want to have an ASP page write back EVERYTHING to the ASP Response. That includes HTTP Headers. I want my ASP to look...
5
8809
by: Katie | last post by:
Hi, I made a posting a while ago regarding doing a binarywrite of a large file in chunks and got a lot of helpful responses. I was able to make it work then. Unfortunately when the project is...
1
2131
by: Anish G | last post by:
Hi, I am trying to print multiple label images in case of ups multi label implementaion. The response i get in XML schema and from that i parsedout the label images and stored in an array and from...
5
12023
by: twiggy182 | last post by:
Hi, I really need you help because I'm not very familliar with ASP and I could not find any solution to my problem. To put you in situation, I have a CGI to which I send a file name, and that...
1
4192
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
11869
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...
2
4215
by: Ron Hinds | last post by:
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...
0
7115
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
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
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,...
1
6858
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
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.