Search code examples
c#asp.netentity-frameworkdebugginghttphandler

Placing a Breakpoint Inside Class Implementing IHttpHandler


I cannot consistently make VS debugger stop in a breakpoint inside ProcessRequest() of a class implementing IHttpHandler. It actually stopped once and then never did it again... I'm working with Visual Studio 2013 and Windows 10.

Here's my sample code:

MyImageHandler:

public class MyImageHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        AwDAL.AwDAL dal = new AwDAL.AwDAL();

        int id = 100;
        byte[] buffer = dal.GetProductPhotoByID(id);

        context.Response.ContentType = "image/gif";
        context.Response.OutputStream.Write(buffer, 0, buffer.Length);
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

WebForm:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Image runat="server" ImageUrl="~/MyImageHandler.ashx" />
    </div>
    </form>
</body>
</html>

It loads the image with no problem:

enter image description here


Solution

  • The problem happens only with Microsoft Edge, but not IE or Firefox.