ASP.Net HttpHandler ProcessRequest() 触发两次

发布于 2024-09-06 02:49:09 字数 363 浏览 1 评论 0原文

我有一个奇怪的问题,我有一个 HttpHandler ,其 ProcessRequest() 事件触发两次。

除了指向静态方法的指针之外,我在类中没有其他任何东西,所以我迷路了。

我做了一些谷歌搜索,但无济于事,即使似乎有些人也遇到类似的问题:

代码:

    public bool IsReusable
    {
        get { return true; }
    }

    public void ProcessRequest(HttpContext context)
    {
        Common.Tracker.TrackPageView(context);
    }

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);
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

白昼 2024-09-13 02:49:09

废弃这个。

我一直在 Firefox 中进行测试,只有当我直接调用处理程序时才会发生这种情况。

如果我将处理程序设置为图像源,则不会发生这种情况。

另外,在 IE 中,这种情况不会发生——只有 Firefox 才会发生这种情况。

我认为这可能是我的扩展(特别是 firebug 或 YSLOW),所以我手动将它们一一禁用,但它仍然发生,所以我不知道,但 Firefox 对页面进行了两次调用。

也许它与这篇旧文章类似,因为我返回 GIF 作为内容类型:
http://www.hanselman.com/blog/InternetExplorerAndTheMagicOfMicrosoftKBArticleQ293792.aspx

希望这对某人有帮助因为那是几个小时我永远不会回来......

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...

幽蝶幻影 2024-09-13 02:49:09

您似乎正在尝试跟踪页面浏览量;客户端上的某些内容是否会导致页面/处理程序被调用两次?当发送到浏览器的 html 包含不带 src 属性的 img 标签时,我过去见过类似的行为。这只发生在 FireFox 中,但导致页面被调用两次。建议:查看是否有没有src标签的图片;使用 Fiddler 或 FireBug 检查 http 流量并确保您不会无意中调用处理程序两次。更多细节也会有帮助。希望这有帮助。

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.

蛮可爱 2024-09-13 02:49:09

浏览器是否正在尝试获取网站图标?

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

红衣飘飘貌似仙 2024-09-13 02:49:09

我在我的项目中观察到相同的行为,并将其跟踪到具有空 src 值的 img 标签。我正在 Chrome 浏览器上进行测试,但不认为浏览器与我的情况有任何关系。

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.

心如荒岛 2024-09-13 02:49:09

如果您使用隐身模式,它会触发一次。必须是扩展之一。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文