有个页面 页面上有些信息(一些文本信息) 我在Page_Load
代码如下:
protected void Page_Load(object sender, EventArgs e)
    {
        FileStream fs = new FileStream(@"C:\Documents and Settings\Developer\桌面\94f6b0begw1dnw55ez8dbg.gif", FileMode.Open, FileAccess.Read);
        int fslength=(int)fs.Length;
        byte[] bimg = new byte[fslength];
        fs.Read(bimg, 0, fslength);
        fs.Close();
        Response.ClearContent();
        Response.ContentType = "image/gif";
        Response.OutputStream.Write(bimg, 0, fslength);
        Response.End();
    }
用二进制流输出图片 但是访问这个页面的时候显示就只有这张图片 页面上本来的东西就不见了 求大神帮帮忙 怎么才显示本页面的所有信息及输出的图片

解决方案 »

  1.   

    Response.ClearContent();因为你这里重写类响应流。即使上面没有ClearContent也不行的。
    响应流已经被改掉了。为什么不直接绑定图片呢?路径都有。
      

  2.   

    image.syc="1.gif";显示
    或嵌套img src="xx.aspx?type=image">
    Page_Load:
    if(Request.QueryString["type"]=="image")
    {
    Response.ClearContent();
    Response.ContentType = "image/Gif";
    Response.BinaryWrite(ms.ToArray());
    Response.End();
    }
      

  3.   

    把Response.OutputStream.Write(bimg, 0, fslength);
    改成Response.BinaryWrite(ConvertType.StreamToBytes(fs));
      

  4.   

    Bitmap bitmap = new Bitmap(stream);Image bufferImage = bitmap as Image ;
      

  5.   


    ConvertType 是哪个命名空间的啊?
      

  6.   


    Image bufferImage = bitmap as Image;
    无法通过引用转换
      

  7.   

    public class ConvertType
        {        public static byte[] StreamToBytes(Stream stream)
            {            byte[] bytes = new byte[stream.Length];            stream.Read(bytes, 0, bytes.Length);            // 设置当前流的位置为流的开始            stream.Seek(0, SeekOrigin.Begin);            return bytes;        }
        }
      

  8.   

    <img src="a.aspx" />
    --------------------------
    一个图片就要求一个响应的http输出流
      

  9.   

    方法用错了,你写方法本身就只能输出一张图片而不是整个html如果是本页连图片带html一起输出的应该是把图片流用base64编码以后,加到img标签里面,不过我们不建议如此,无端让html变胖了你应该如10楼那样,采用另外一个页面输出才是正解
      

  10.   

    有关base64的解法你可以看
    http://staratsky.iteye.com/blog/314651不过你应该注意到了,这种解法太不划算了,html被人为“增肥”
      

  11.   

    Refer:
    http://www.cnblogs.com/insus/articles/2012733.html
      

  12.   

    页面的Type都改了Response.ContentType = "image/gif"; 只能输出图片了。
      

  13.   

    把你输出二进制图片的代码放在单独的页面里面用来输出图片。例如页面名称为Image.aspx。
    再绑定到空间上 <img id="image" src="Image.aspx" />