我無法弄清楚爲什麼當我嘗試輸出圖像和一行文字時,我只能看到圖像我做錯了什麼?Response.Write輸出問題
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();
什麼是ContentType設置爲? – Patrick 2011-03-14 18:12:32