Display Image using ashx Handler

孤街醉人 提交于 2019-11-27 09:29:57

Try setting the ContentType:

context.Response.ContentType = "image/png";

http://www.dotnetperls.com/ashx

Try the following in your ProcessRequest method:

context.Response.ContentType = "image";

using (System.IO.MemoryStream str = new System.IO.MemoryStream(objData.ToArray(), true))
{
       str.Write(objData.ToArray(), 0, objData.ToArray().Length);
       Byte[] bytes = str.ToArray();
       context.Response.BinaryWrite(bytes);
}

where objData is the value you are reading from the database

The ImageUrl only replaces the tilde (~) in the control markup.

Try this instead:

string imageUrl = "~/AvatarImageFetch.ashx?memberid=" + memberid.ToString();
LargeImage.ImageUrl = Page.ResolveUrl(imageUrl);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!