问题描述
调用<asp:ImageID="Image1"runat="server"Height="80px"ImageUrl='<%#"img.ashx?id="+Eval("id")%>'Width="80px"/>.ashx文件publicvoidProcessRequest(HttpContextcontext){stringid=(string)context.Request["id"];my_db.my_data_typetype=(my_db.my_data_type)Enum.Parse(typeof(my_db.my_data_type),ConfigurationManager.AppSettings["dbType"]);if(id!=null){MemoryStreamimgStream;try{my_db.Datadd=newmy_db.Data();byte[]blob=(byte[])dd.Execute_Scalar("selectimgfromenterprisewhereid='"+id+"'");imgStream=newMemoryStream(blob);Imageimg=Image.FromStream(imgStream);HttpContext.Current.Response.ContentType="image/jpeg";img.Save(HttpContext.Current.Response.OutputStream,ImageFormat.Jpg);}finally{imgStream.Close();}}}publicboolIsReusable{get{returnfalse;}}不知道为什么就是显示X,大侠帮忙看看
时间: 2024-08-30 14:34:50