using System;
using System.Web;
using System.IO;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
Int32 regno;
if (context.Request.QueryString["id"] != null)
regno = Convert.ToInt32(context.Request.QueryString["id"]);
else
throw new ArgumentException("No parameter specified");
context.Response.ContentType = "image/jpeg";
Stream strm = ShowImage(regno);
byte[] buffer = new byte[4096];
int byteSeq = strm.Read(buffer, 0, 4096);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 4096);
}
context.Response.BinaryWrite(buffer);
}
public Stream ShowImage(int regno)
{
System.Data.DataTable dt = Student.getStudentData(regno.ToString());
object imgP = dt.Rows[0]["imgattach_p"];
try
{
return new MemoryStream((byte[])imgP);
}
catch
{
return null;
}
}
public bool IsReusable {
get {
return false;
}
}
Just pass the particular row data to get image and get it in your handler.