Retrieving image from SQL (C#) problem

B

Bjorn Sagbakken

This is kind of silly, but I just cannot figure out why:

In ASP.NET 2.0 I am retrieving images from a MS SQL server, and writing them
as binary to a separate page as the url for image controls, everything by
the book. I have been doing this a lot with VB. Now I am writing a new
application in C#, and the strange thng is this:

- it works well in debug mode
- but not on the published folder on the same server (localhost) - image
frames all have a cross in them
- a VB coded Image.aspx works well also on the published folder

Her is the C# code in the Image.aspx file::

.....som init code...

SqlConnection con = new SqlConnection(init.con());
con.Open();
string strSQL = "SELECT img FROM photo where ID= " + ID;
SqlCommand cmd = new SqlCommand(strSQL, con);
imagebyte = (byte[])cmd.ExecuteScalar();
con.Close();
Response.Clear();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(imagebyte);
Response.BufferOutput= true;

--> Why does this work in debug mode, and not on the published folder?

Bjorn
 
B

Bjorn Sagbakken

Eliyahu Goldin said:
If you set Response.BufferOutput= true; you will likely need to call
Response.Flush(); at some stage.

If the page is just serving images, there should not be any reason for
setting Response.BufferOutput= true.

Well, I removed the Response.BufferOutput=true

and still the result is the same: in debug mode this works, but not when
running on the published folder.

Bjorn
 

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

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top