在Firefox页面加载两次火灾

在Firefox页面加载两次火灾

本文介绍了在Firefox页面加载两次火灾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK,首先一些背景:我有一个显示点击(或意见)任何选定的项目数的页面。这被称为在每个页面加载即命中计数器程序

 如果(Request.QueryString.HasKeys())
{
    //从icoming URL例如details.aspx?itemid的= 26获得项目编号    字符串的itemid = Request.Params [itemid的];    如果(!Page.IsPostBack)
    {
        countHit(itemid的);
    }
}

问题:我的期望是,将柜台上的每个页面加载增加1,但在我的DataList和FormView柜台总是落后,走到2即

而不是 1,2,3,4 ,这是 0,2,4,6

看来,页面加载射击两次。后来我发现,当您使用Mozilla Firefox,这才会发生。该页面的行为罚款与其他浏览器如IE

这变得十分沮丧。


解决方案

我见过的Page_Load火两次,如果你有一个< ASP:图像> < IMG =服务器方式> 的页面,没有它是指定的的src 属性

可能是值得一试。

OK, first some background: I have a page showing the number of hits(or views) of any selected item. The hit counter procedure that is called at every page load i.e

if (Request.QueryString.HasKeys())
{
    // get item id from icoming url e.g details.aspx?itemid=26

    string itemid = Request.Params["itemid"];

    if (!Page.IsPostBack)
    {
        countHit(itemid);
    }
}

The problem: my expectation was that the counter would be increased by 1 on every page load but the counters on my datalist and formview are always behind and stepped by 2 i.e

instead of 1, 2, 3, 4, it's 0, 2 , 4, 6.

It seems that the page load is firing twice. Later I discovered that this only happens when you are using Mozilla Firefox. The page behaves fine with other browsers like IE

This becoming quite frustrating.

解决方案

I've seen Page_Load fire twice if you have an <asp:Image> or an <img runat="server"> on the page that doesn't have it's src attribute specified.

Could be worth a look.

这篇关于在Firefox页面加载两次火灾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 07:51