有人能说出如何在数据库(二进制流)中显示转发器控件中的图像吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
我会创建一个返回图像的处理程序:
System.IO.Stream responseStream =//stream from database
MemoryStream mem = new MemoryStream();
CopyStream(responseStream, mem);
byte[] buffer = mem.GetBuffer();
context.Response.Clear();
context.Response.AddHeader("content-disposition", "attachment;filename="image");
context.Response.ContentType = "image/PNG";
context.Response.BinaryWrite(buffer);
context.Response.End();
然后在你的转发器中,我会将处理程序称为:
<img src="handlerName.ashx?id=<%# Eval("Id")%>" />