Response.BinaryWrite Not Returning Result

  • Thread starter Steve Harclerode
  • Start date

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.ContentType =
Response.AddHeader("Content-Disposition", "attachment;
filename=" +

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
- 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?

Steve Harclerode

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

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

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

Latest member

Latest Threads