S
Steve Harclerode
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?
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?