问题描述
在数据库存的是二进制的图片现在用ashx取出来但是无法显示这是gridview模版列的控件<imgalt=""src='<%#"img.ashx?id="+Eval("id")%>'/>下面是img.ashx文件中的代码<%@WebHandlerLanguage="C#"Class="Handler"%>usingSystem;usingSystem.Web;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Drawing;usingSystem.Drawing.Imaging;usingSystem.IO;usingSystem.Configuration;publicclassHandler:IHttpHandler{publicvoidProcessRequest(HttpContextcontext){if(context.Request.QueryString["id"]!=null){stringid=context.Request.QueryString["id"].ToString();try{my_db.Datadd=newmy_db.Data();byte[]img=(byte[])dd.Execute_Scalar("selectimgfromenterprisewhereid="+id);context.Response.ContentType="image/gif";context.Response.BinaryWrite(img);context.Response.End();}catch(Exceptionex){context.Response.Write("<script>alert('"+ex.Message+"');</script>");}}}publicboolIsReusable{get{returntrue;}}}请大家帮忙吧,已经两天了