5

I have a strange issue where i have a a HttpHandler having its ProcessRequest() event firing twice.

i have nothing else in the class except a pointer to a static method so i'm lost.

I have done some googling to no avail even thought it appears a few people are having similar issues:

Code:

    public bool IsReusable
    {
        get { return true; }
    }

    public void ProcessRequest(HttpContext context)
    {
        Common.Tracker.TrackPageView(context);
    }
Doug
  • 6,460
  • 5
  • 59
  • 83

3 Answers3

10

Scrap this.

I have been testing in firefox and this ONLY happens when i directly call the handler.

If i have the handler set up as an image src this doesn't happen.

additionally in IE this doesn't happen - it is firefox only.

i thought it could be my extensions (specifically firebug or YSLOW), so i manually disabled them one by one and it was still happening so i have no idea but firefox makes two calls to a page.

maybe it is similar to this old post as i'm returning a GIF as the content type: http://www.hanselman.com/blog/InternetExplorerAndTheMagicOfMicrosoftKBArticleQ293792.aspx

hope this helps someone as that is a couple of hours i'll never get back...

Doug
  • 6,460
  • 5
  • 59
  • 83
  • Thanks, this helped stop me from going crazy. As much as I love FF, it does weird stuff sometimes. – Kon Apr 08 '11 at 18:03
  • i have the same problem but its in chrome , i want my handler to be fired when i call it not when the page loads..any idea how can i do it plz – Armance Sep 08 '11 at 12:05
  • What do you mean by "handler set up as an image src" can you please elaborate? Trying to solve a similar problem. – Karthik Murugesan Dec 10 '11 at 08:16
  • I am referring to having an HTML Image with its src="" set to the path of a handler. I have a handler that shows images. – Doug Apr 22 '12 at 01:25
  • It happens also in IE 9 - I've written an ashx HTTP handler to upload files. When the maxRequestLength value is too low then the error "Maximum request length exceeded" occurs, I catch it and write a response back. Strangely the ProcessRequest handler is fired twice and there seems to be no way to correctly handle this condition! – Matt Apr 10 '13 at 08:27
  • I confirm this. It fires twice ONLY when its directly called with FireFox. But, even then I don't know why. Still, its not happening when used indirectly. – E-A Nov 30 '13 at 06:55
1

It looks like you are attempting to track a page view; could something on the client be causing the page/handler to get called twice? I have seen similar behavior in the past when the html sent to the browser contained an img tag without the src attribute. This only happened in FireFox, but was causing the page to get called twice. Suggestions: See if there are any images without src tags; use Fiddler or FireBug to inspect the http traffic and ensure that you are not inadvertently calling the handler twice. More details would also be helpful. Hope this helps.

David A Moss
  • 239
  • 1
  • 1
  • I am directly calling the handler. I intend to have it displayed as a tracking pixel but havent got that far. i am simply calling it in a browser. it then streams a gif file to the browser. this is working fine, it just fires the method twice?? – Doug Jun 18 '10 at 04:51
1

Could it have been that the browser was trying to get a favicon?

Gordon Thompson
  • 4,764
  • 8
  • 48
  • 62