I cant figure out why when I try to output an image and a line of text below I only get the image what Am I doing wrong?
SqlConnection cn = new SqlConnection("CONNECTIONINFO HERE");
SqlCommand cmd = new SqlCommand("SELECT * FROM test WHERE id=" + Request.QueryString["id"], cn);
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read()) //check to see if image was found
{
Response.ContentType = dr["fileType"].ToString();
Response.BinaryWrite((byte[])dr["imagesmall"]);
Response.Write("<br/>This is your image, if this is incorrect please contact the administrator.");
}
cn.Close();
Create a HttpHandler for your images and call it from an image tag.
like this:
Then use it like this:
You will need to configure the handler in web.config or in IIS 7 if that is what you are using.
Here is how: http://mvolo.com/blogs/serverside/archive/2007/08/15/Developing-IIS7-web-server-features-with-the-.NET-framework.aspx