有个页面 页面上有些信息(一些文本信息) 我在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();
}
用二进制流输出图片 但是访问这个页面的时候显示就只有这张图片 页面上本来的东西就不见了 求大神帮帮忙 怎么才显示本页面的所有信息及输出的图片
代码如下:
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();
}
用二进制流输出图片 但是访问这个页面的时候显示就只有这张图片 页面上本来的东西就不见了 求大神帮帮忙 怎么才显示本页面的所有信息及输出的图片
解决方案 »
- 怎么在404.aspx中显示找不到的页面地址?
- 应用程序池
- 点击GridView中的字段弹出一个小的窗口?
- 想做一个酒店管理系统,大家说说是B/S模式好还是C/S模式好?
- 请问为什么用Infragrist 的例子项目在设计时加载会出现创建控件时出错呢?
- 请教学会了使用硕思闪客精灵还需不需要再学flash啊????为什么啊???菜鸟的困惑啊!我是菜鸟,别笑我啊!谢谢!
- DNN 模块的问题
- treeview 节点必须选择两次
- 关于表中字段关联的问题。急!急!急!在线等待!
- GG放分,结识编程MM~~~~(注:恐龙不要进)
- 存储过程问题。
- Label控件怎么实现textbox空间一样的换行、缩进格式?
响应流已经被改掉了。为什么不直接绑定图片呢?路径都有。
或嵌套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();
}
改成Response.BinaryWrite(ConvertType.StreamToBytes(fs));
ConvertType 是哪个命名空间的啊?
Image bufferImage = bitmap as Image;
无法通过引用转换
{ 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; }
}
--------------------------
一个图片就要求一个响应的http输出流
http://staratsky.iteye.com/blog/314651不过你应该注意到了,这种解法太不划算了,html被人为“增肥”
http://www.cnblogs.com/insus/articles/2012733.html
再绑定到空间上 <img id="image" src="Image.aspx" />