Sql - 从DB读取图像

时间:2012-04-09 23:38:41

标签: sql image httphandler

从我的数据库中读取图像时,我一直收到错误图像图标。

这是HttpHandler代码:

public void ProcessRequest(HttpContext context) {
    ....
    //After we got the data table:
    byte[] image = (byte[])dt.Rows[0]["Picture"];
    context.Response.ContentType = dt.Rows[0]["PictureType"].ToString();
    context.Response.BinaryWrite(image);
}

我确实检查并看到image不为空(只是一个非常大的数组,应该是这样),PictureType确实保存了之前保存在数据库中的图片类型。但是在调用处理程序时我仍然看到错误图像图标:

<img src='myhandler.ashx?imgid=someid'/>

出现这种情况的原因是什么?

0 个答案:

没有答案