要设置response.contenttype,好像word是application/word,忘记了

解决方案 »

  1.   

    Response.ContentType = "image/gif";
      

  2.   


    我加了也是无效,下面是我解决的代码
                string sql = "select * from Doc where id=@id";
                SqlCommand comd = new SqlCommand(sql, Conn);
                comd.Parameters.Add("@id", SqlDbType.SmallInt, 10).Value = Int32.Parse(ID);
                Conn.Open();
                SqlDataReader dr = comd.ExecuteReader();            if (dr.Read())
                {
                    string DocState = dr.GetValue(0).ToString();
                    Response.BinaryWrite((Byte[])dr["DocContent"]);   //读取二进制的文件
                }
                dr.Close();
                Conn.Close();
                Response.End();
    不知道为什么,我用这样方法读取就可以了