I am using HttpHandler to retrieve image from database and then use the Handler as ImageUrl in an Image web control on my web page (aspx). The code is shown below. But it does not work and so far I could not figure out why. The issue is HttpHandler is never been hit, if I keep the breakpoint at processrequest() it is never hit
Below is the simple code in Handler
public class ImageHandler : IHttpHandler
{
StaffMemberRepository db = new StaffMemberRepository();
public void ProcessRequest(HttpContext context)
{
int id = Convert.ToInt32(context.Request.QueryString["id"].ToString());
byte[] image = db.GetImage(id);
context.Response.ContentType = "image/jpg";
context.Response.BinaryWrite(image);
}
public bool IsReusable
{
get
{
return false;
}
}
}
and below is the markup in my webpage
asp:Image ID="imgStaff" runat="server" ImageAlign="Middle" ImageUrl="~/Handlers/ImageHandler.ashx?id=2"
Can someone let me know what I am doing wrong here?