ASP.Net HttpHandler ProcessRequest() firing twice
Asked Answered
N

5

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);
    }
Neral answered 18/6, 2010 at 4:11 Comment(0)
N
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...

Neral answered 18/6, 2010 at 6:53 Comment(6)
Thanks, this helped stop me from going crazy. As much as I love FF, it does weird stuff sometimes.Lauds
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 plzAlcott
What do you mean by "handler set up as an image src" can you please elaborate? Trying to solve a similar problem.Typhus
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.Neral
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!Clinton
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.Externality
V
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.

Valentinavalentine answered 18/6, 2010 at 4:44 Comment(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??Neral
F
1

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

Fonz answered 21/6, 2011 at 8:50 Comment(0)
C
0

I was observing the same behavior in my project and tracked it down to an img tag with an empty src value. I'm testing on a Chrome browser but do not believe that the browser had anything to do with it in my case.

Cacoepy answered 22/11, 2023 at 19:18 Comment(0)
S
0

If you use incognito mode, it fires once. Must be one of the extensions.

Sucking answered 28/12, 2023 at 13:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.