页面在谷歌chrome中加载两次

时间:2021-01-05 01:14:23

Does anyone have any problems with Page_Load being executed twice in Google Chrome? It's a short question, i do not know what else to explain...

有谁对在谷歌Chrome中执行两次Page_Load有问题吗?这是一个很短的问题,我不知道还能解释什么。

I have a simple asp.net page and in Firefox and IE all it's working fine. But in Chrome the Page_Load is fired twice...

我有一个简单的asp.net页面,在Firefox和IE中一切正常。但是在Chrome中Page_Load被触发两次……

Anyone has any ideas why?

有人知道为什么吗?

Later EDIT: - what is strange is that i have 4 repeaters... binded with random values. The random methods are twice fired (because of page loaded twice) but the repeaters takes the INITIALLY values...so, the 2nd post back is somehow raised after the rendering step.

后来编辑:-奇怪的是我有4个中继…与随机值绑定。随机方法被两次触发(因为页面加载了两次),但是中继器接受初始值……所以,第二个post back在呈现步骤之后会被提升。

3rd edit: It happens ONLY at the refresh!

第三次编辑:它只在刷新时发生!

Solution (in my case): There was an empty img src, and that was the cause

解决方案(在我的例子中):有一个空的img src,这就是原因

19 个解决方案

#1


38  

I notice this same issue in IE if the page contains img tags that don't have a src attribute (or the src is empty, etc). Not sure if Chrome does the same thing, but worth checking, right?

我注意到IE中同样的问题,如果页面包含没有src属性的img标记(或者src是空的,等等)。不确定Chrome是否做了同样的事情,但值得一试,对吗?

#2


11  

For me the problem was because of the extension Firebug Lite for Google Chrome. Once deactivated the page only loads once.

对我来说,问题在于谷歌Chrome的扩展Firebug Lite。一旦禁用页面,只加载一次。

#3


6  

I had a very similar problem: Chrome and Firefox loading the page twice, Internet Explorer loading it once.

我有一个非常相似的问题:Chrome和Firefox加载页面两次,ie加载一次。

The problem was because of my .htaccess:

问题在于我的。htaccess:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

When the browsers were requesting a favicon.ico, my index.php page was called, thus creating a double access to the server. My solution was to create a favicon.ico, although I could also had index.php handle that special case, or even .htaccess, but I needed a favicon.ico anyway :)

当浏览器请求一个图标时。图标,我的指数。调用php页面,从而创建对服务器的双重访问。我的解决方案是创建一个图标。ico,虽然我也可以有索引。php处理这种特殊情况,甚至是.htaccess,但我需要一个图标。ico呢:)

#4


5  

I had the same stupid problem. Page loads twice and the updates went blank.

我也有同样愚蠢的问题。页面加载两次,更新变为空白。

Thanks to this posting I checked my CSS sheet.

感谢这篇文章,我检查了我的CSS表格。

I removed this line:

我删除了这条线:

body { background-image: url(); }

身体{背景图片:url();}

That was the problem

这是问题

#5


3  

I recently had this issue with Chrome rendering twice too, the cause of this issue is

我最近也遇到过两次Chrome渲染的问题,这个问题的原因是

<iframe src="#"></iframe>

once I set it to

一旦我设置为

<iframe></iframe>

or completely remove iframe then the double rendering no longer appears.

或者完全删除iframe,则不再出现双渲染。

#6


1  

In addition to Chris Shaffer's answer which got me on the right track, I'd like to add that in my case there was also a <script> tag with an empty src that caused the problem.

除了Chris Shaffer的回答让我走上了正确的道路之外,我还想补充一点,在我的例子中,还有一个带有空src的

Perhaps it applies to all elements with an empty src.

也许它适用于所有带空src的元素。

#7


0  

So far I've used Chrome to test ASP.NET pages many times and never encountered this. What are you doing client-side that could cause this? Are you doing any AJAX stuff?

到目前为止,我已经使用Chrome来测试ASP。NET页面多次出现,从未遇到过这种情况。你在客户端做什么会导致这种情况?你在做AJAX方面的工作吗?

#8


0  

I noticed that this started happening to me when I switched to Chrome v.4, the developer's channel, so that i could start using extensions. Didn't seem to be a problem with v.3, the stable version.

我注意到当我切换到Chrome v时,这种情况开始发生在我身上。4、开发人员的通道,以便我可以开始使用扩展。看起来并不是v的问题。3、稳定的版本。

#9


0  

In your Page_Load, check the value of Page.IsPostBack and Page.IsCallback to see if they differ between the two calls. If they're different, it could be some javascript reexecuting or chrome following a redirect twice or something odd like that.

在Page_Load中,检查页面的值。IsPostBack和页面。IsCallback,看看两个调用之间是否有差异。如果它们是不同的,可以是一些javascript重新执行,或者chrome重定向两次或者类似的奇怪的东西。

#10


0  

I encountered a similar problem with PHP and Firefox.

我在PHP和Firefox中遇到过类似的问题。

The problem was coming from a faulty style definition that Firefox interpreted to reload the page. I cannot remember exactly what it was but int the idea, could be something like

问题来自于一个错误的样式定义,Firefox将其解释为重新加载页面。我记不太清楚它是什么,但在这个想法中,可能是这样的

.my_class    { background: url(#); }

I would advice to try to isolate first your CSS and then your HTML sections to check if the problem might come from it.

我建议先把CSS和HTML部分分离出来,看看问题是否来自于它。

#11


0  

If you set your image tag src to # or empty it will cause twice pageload calling, i faced this on chrome and before on firefox.

如果您将图像标记src设置为#或空,将导致两次pageload调用,我在chrome和firefox上都遇到过这种情况。

you can put any char or string value instead of empty or # to solve this issue.

您可以将任何char或string值替换为empty或#来解决这个问题。

#12


0  

It also doesnt like empty href's

它也不喜欢空的href。

I had an empty favicon link tag and it did the same thing. Whoever said about the empty src put me onto that, just stripped out everything until it started working

我有一个空的favicon链接标签,它也做了同样的事情。不管是谁说的空src让我这么做,只是把一切都剥离出来,直到它开始工作

#13


0  

Gecko based browsers apparently do this when the markup is incorrect. That means XHTML AND CSS.

当标记不正确时,基于Gecko的浏览器显然会这样做。这意味着XHTML和CSS。

Here is a great post about the issue: http://www.110mb.com/forum/how-to-stop-firefox-dual-pageloads-t27704.0.html

这里有一个关于这个问题的很棒的帖子:http://www.110mb.com/forum/how- stop-firefox- double -pageloads-t27704.0.html

That's why some of you guys are getting the problem when you have a blank src attribute or a blank href attribute. Incorrect syntax, the browser reads it as an "error". I guess it's a more unobtrusive type of error that you would otherwise not even notice, but due to the nature of the page you're working on it's become apparent and presented itself as a rather obtrusive problem.

这就是为什么当你有一个空白的src属性或一个空白的href属性时,你们中的一些人会遇到这个问题。语法不正确,浏览器会将其读取为“错误”。我猜这是一种不太显眼的错误,你甚至不会注意到它,但由于你正在处理的页面的性质,它变得很明显,并且表现为一个相当突兀的问题。

What certain browsers consider to be an 'error' and what is 'passable' is probably slightly different too, that would explain why some of you are having the problem in FF and not in Chrome and visa versa.

某些浏览器所认为的“错误”和“可通过”可能也略有不同,这可以解释为什么有些人在FF而不是在Chrome和visa中有问题。

Just be thankful you're not in my shoes. I've got a page that's sending an email out twice due to this issue and there's no way I can fix the bad markup because there's just simply too much of it to fix being generated in far too many places, a lot of the CSS and HTML issues are dynamically driven too unfortunately.

只是要感谢你没有站在我的立场。我有一个页面,发送电子邮件两次由于这个问题,我没有办法可以解决这个坏标记仅仅因为有太多修复产生在太多的地方,很多CSS和HTML的问题是动态驱动太不幸了。

I still don't understand the reasoning behind it grabbing the page twice though when it encounters non-compliant issues of this nature though.

我仍然不理解为什么它会在遇到这种性质的不兼容问题时两次抓取页面。

#14


0  

I'm also having this issue.

我也有这个问题。

Funny, I added "visible=false" to the whole "form" tag making the page totally empty - it still loads twice. I also tweaked the DOCTYPE, checked the img-tags for empty sources etc. etc. etc.

有趣的是,我在整个“表单”标签中添加了“可见=假”,使得页面完全为空——它仍然加载了两次。我还修改了DOCTYPE,检查了img标签的空源等。

It still loads twice.

它仍然加载两次。

BUT I noticed that this happens on "localhost" only. Remote websites work fine.

但我注意到,这只发生在“localhost”上。远程网站正常运行。

I thought may be is has something to do with DNS, but "127.0.0.1" also loads twice. This drives me nuts...

我认为可能是与DNS有关,但是“127.0.0.1”也加载了两次。这真让我发狂……

#15


0  

Ran into the same issue. I was using DOM Snitch.

遇到了同样的问题。我用的是DOM Snitch。

I disabled it and it immediately stopped posting back twice.

我把它禁用了,它立刻停止了两次上传。

After looking at it, it seems to contain 2 tags without an href attribute. Because it's a Chrome extension it's injected into the DOM at the client and I suppose this causes a Webforms page to post back twice.

查看它之后,它似乎包含两个没有href属性的标记。因为它是一个Chrome扩展,它被注入到客户端的DOM中,我想这会导致Webforms页面返回两次。

On the off chance someone sees this, be sure to check any extensions and/or plugins you are using.

万一有人看到这个,一定要检查你正在使用的任何扩展和/或插件。

#16


0  

I had the same issue. However my "mistake" was located in my css file.

我也有同样的问题。然而,我的“错误”位于我的css文件中。

I was using .htaccess to rewrite everything back to my root folder but used

我使用。htaccess将所有内容重写回根文件夹,但使用了

background-image: url('../img/login_facebook.png')

in my css file. I removed the .. and the problem was solved.

在我的css文件。我删除了. .问题解决了。

#17


0  

This may be a problem with one of the extensions/plugins. Try out the incognito mode - this helped me once.

这可能是一个扩展/插件的问题。尝试隐身模式-这帮助了我一次。

#18


0  

Here is another great article on why this occurs: https://www.nczonline.net/blog/2009/11/30/empty-image-src-can-destroy-your-site/

下面是另一篇关于为什么会发生这种情况的文章:https://www.nczonline.net/blog/2009/11/30/empty-image-src-can-销毁你的网站/

I was getting the same error using Chrome in an ASP.NET site. I was getting the page life-cycle firing again with IsPostBack set to False.

我在ASP中使用Chrome的时候也犯了同样的错误。网的网站。我在IsPostBack设置为False的情况下再次启动页面生命周期。

This caused all sorts of issues for me.

这给我带来了各种各样的问题。

#19


-2  

I believe it is just how Google Chrome works. I put some code on my index page to write to a file with the file name that was loaded, and every time I load the page (using refresh or a new window) it puts 2 results in the file.

我相信这就是谷歌Chrome的工作原理。我在我的索引页上放了一些代码,以写入一个已加载文件名的文件,每次我加载页面(使用refresh或一个新窗口),它都会在文件中放入两个结果。

EDIT: I renamed my index file to test.php and ran it again. This time it only had one result. This problem is pissing me off.

编辑:我将索引文件重新命名为test。然后再次运行。这次只有一个结果。这个问题让我很生气。

EDIT: I renamed my file back to index.php and ran it. Same problem. Then I renamed my .htaccess (for mod_rewrite) to htaccess so it wouldn't be parsed and the problem is gone. After I found this out, I disabled url rewriting in the .htaccess file and the problem was still gone (finally). I did one more test (if people are still reading this crap) and found that google loads the page twice when you redirect from the .htaccess file. I found a little workaround that seems to fix the problem.

编辑:我将文件重命名为索引。php和跑。同样的问题。然后我将.htaccess(用于mod_rewrite)重命名为htaccess,这样就不会解析它,问题也就解决了。在我发现这个之后,我禁用了.htaccess文件中的url重写,问题仍然没有解决(最后)。我又做了一个测试(如果人们还在读这个垃圾),发现当你从。htaccess文件重定向时,谷歌会加载两次页面。我找到了一个解决问题的方法。

Not sure if this applies to asp.net. I only know php coding and apache servers.

不确定这是否适用于asp.net。我只知道php编码和apache服务器。

#1


38  

I notice this same issue in IE if the page contains img tags that don't have a src attribute (or the src is empty, etc). Not sure if Chrome does the same thing, but worth checking, right?

我注意到IE中同样的问题,如果页面包含没有src属性的img标记(或者src是空的,等等)。不确定Chrome是否做了同样的事情,但值得一试,对吗?

#2


11  

For me the problem was because of the extension Firebug Lite for Google Chrome. Once deactivated the page only loads once.

对我来说,问题在于谷歌Chrome的扩展Firebug Lite。一旦禁用页面,只加载一次。

#3


6  

I had a very similar problem: Chrome and Firefox loading the page twice, Internet Explorer loading it once.

我有一个非常相似的问题:Chrome和Firefox加载页面两次,ie加载一次。

The problem was because of my .htaccess:

问题在于我的。htaccess:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

When the browsers were requesting a favicon.ico, my index.php page was called, thus creating a double access to the server. My solution was to create a favicon.ico, although I could also had index.php handle that special case, or even .htaccess, but I needed a favicon.ico anyway :)

当浏览器请求一个图标时。图标,我的指数。调用php页面,从而创建对服务器的双重访问。我的解决方案是创建一个图标。ico,虽然我也可以有索引。php处理这种特殊情况,甚至是.htaccess,但我需要一个图标。ico呢:)

#4


5  

I had the same stupid problem. Page loads twice and the updates went blank.

我也有同样愚蠢的问题。页面加载两次,更新变为空白。

Thanks to this posting I checked my CSS sheet.

感谢这篇文章,我检查了我的CSS表格。

I removed this line:

我删除了这条线:

body { background-image: url(); }

身体{背景图片:url();}

That was the problem

这是问题

#5


3  

I recently had this issue with Chrome rendering twice too, the cause of this issue is

我最近也遇到过两次Chrome渲染的问题,这个问题的原因是

<iframe src="#"></iframe>

once I set it to

一旦我设置为

<iframe></iframe>

or completely remove iframe then the double rendering no longer appears.

或者完全删除iframe,则不再出现双渲染。

#6


1  

In addition to Chris Shaffer's answer which got me on the right track, I'd like to add that in my case there was also a <script> tag with an empty src that caused the problem.

除了Chris Shaffer的回答让我走上了正确的道路之外,我还想补充一点,在我的例子中,还有一个带有空src的

Perhaps it applies to all elements with an empty src.

也许它适用于所有带空src的元素。

#7


0  

So far I've used Chrome to test ASP.NET pages many times and never encountered this. What are you doing client-side that could cause this? Are you doing any AJAX stuff?

到目前为止,我已经使用Chrome来测试ASP。NET页面多次出现,从未遇到过这种情况。你在客户端做什么会导致这种情况?你在做AJAX方面的工作吗?

#8


0  

I noticed that this started happening to me when I switched to Chrome v.4, the developer's channel, so that i could start using extensions. Didn't seem to be a problem with v.3, the stable version.

我注意到当我切换到Chrome v时,这种情况开始发生在我身上。4、开发人员的通道,以便我可以开始使用扩展。看起来并不是v的问题。3、稳定的版本。

#9


0  

In your Page_Load, check the value of Page.IsPostBack and Page.IsCallback to see if they differ between the two calls. If they're different, it could be some javascript reexecuting or chrome following a redirect twice or something odd like that.

在Page_Load中,检查页面的值。IsPostBack和页面。IsCallback,看看两个调用之间是否有差异。如果它们是不同的,可以是一些javascript重新执行,或者chrome重定向两次或者类似的奇怪的东西。

#10


0  

I encountered a similar problem with PHP and Firefox.

我在PHP和Firefox中遇到过类似的问题。

The problem was coming from a faulty style definition that Firefox interpreted to reload the page. I cannot remember exactly what it was but int the idea, could be something like

问题来自于一个错误的样式定义,Firefox将其解释为重新加载页面。我记不太清楚它是什么,但在这个想法中,可能是这样的

.my_class    { background: url(#); }

I would advice to try to isolate first your CSS and then your HTML sections to check if the problem might come from it.

我建议先把CSS和HTML部分分离出来,看看问题是否来自于它。

#11


0  

If you set your image tag src to # or empty it will cause twice pageload calling, i faced this on chrome and before on firefox.

如果您将图像标记src设置为#或空,将导致两次pageload调用,我在chrome和firefox上都遇到过这种情况。

you can put any char or string value instead of empty or # to solve this issue.

您可以将任何char或string值替换为empty或#来解决这个问题。

#12


0  

It also doesnt like empty href's

它也不喜欢空的href。

I had an empty favicon link tag and it did the same thing. Whoever said about the empty src put me onto that, just stripped out everything until it started working

我有一个空的favicon链接标签,它也做了同样的事情。不管是谁说的空src让我这么做,只是把一切都剥离出来,直到它开始工作

#13


0  

Gecko based browsers apparently do this when the markup is incorrect. That means XHTML AND CSS.

当标记不正确时,基于Gecko的浏览器显然会这样做。这意味着XHTML和CSS。

Here is a great post about the issue: http://www.110mb.com/forum/how-to-stop-firefox-dual-pageloads-t27704.0.html

这里有一个关于这个问题的很棒的帖子:http://www.110mb.com/forum/how- stop-firefox- double -pageloads-t27704.0.html

That's why some of you guys are getting the problem when you have a blank src attribute or a blank href attribute. Incorrect syntax, the browser reads it as an "error". I guess it's a more unobtrusive type of error that you would otherwise not even notice, but due to the nature of the page you're working on it's become apparent and presented itself as a rather obtrusive problem.

这就是为什么当你有一个空白的src属性或一个空白的href属性时,你们中的一些人会遇到这个问题。语法不正确,浏览器会将其读取为“错误”。我猜这是一种不太显眼的错误,你甚至不会注意到它,但由于你正在处理的页面的性质,它变得很明显,并且表现为一个相当突兀的问题。

What certain browsers consider to be an 'error' and what is 'passable' is probably slightly different too, that would explain why some of you are having the problem in FF and not in Chrome and visa versa.

某些浏览器所认为的“错误”和“可通过”可能也略有不同,这可以解释为什么有些人在FF而不是在Chrome和visa中有问题。

Just be thankful you're not in my shoes. I've got a page that's sending an email out twice due to this issue and there's no way I can fix the bad markup because there's just simply too much of it to fix being generated in far too many places, a lot of the CSS and HTML issues are dynamically driven too unfortunately.

只是要感谢你没有站在我的立场。我有一个页面,发送电子邮件两次由于这个问题,我没有办法可以解决这个坏标记仅仅因为有太多修复产生在太多的地方,很多CSS和HTML的问题是动态驱动太不幸了。

I still don't understand the reasoning behind it grabbing the page twice though when it encounters non-compliant issues of this nature though.

我仍然不理解为什么它会在遇到这种性质的不兼容问题时两次抓取页面。

#14


0  

I'm also having this issue.

我也有这个问题。

Funny, I added "visible=false" to the whole "form" tag making the page totally empty - it still loads twice. I also tweaked the DOCTYPE, checked the img-tags for empty sources etc. etc. etc.

有趣的是,我在整个“表单”标签中添加了“可见=假”,使得页面完全为空——它仍然加载了两次。我还修改了DOCTYPE,检查了img标签的空源等。

It still loads twice.

它仍然加载两次。

BUT I noticed that this happens on "localhost" only. Remote websites work fine.

但我注意到,这只发生在“localhost”上。远程网站正常运行。

I thought may be is has something to do with DNS, but "127.0.0.1" also loads twice. This drives me nuts...

我认为可能是与DNS有关,但是“127.0.0.1”也加载了两次。这真让我发狂……

#15


0  

Ran into the same issue. I was using DOM Snitch.

遇到了同样的问题。我用的是DOM Snitch。

I disabled it and it immediately stopped posting back twice.

我把它禁用了,它立刻停止了两次上传。

After looking at it, it seems to contain 2 tags without an href attribute. Because it's a Chrome extension it's injected into the DOM at the client and I suppose this causes a Webforms page to post back twice.

查看它之后,它似乎包含两个没有href属性的标记。因为它是一个Chrome扩展,它被注入到客户端的DOM中,我想这会导致Webforms页面返回两次。

On the off chance someone sees this, be sure to check any extensions and/or plugins you are using.

万一有人看到这个,一定要检查你正在使用的任何扩展和/或插件。

#16


0  

I had the same issue. However my "mistake" was located in my css file.

我也有同样的问题。然而,我的“错误”位于我的css文件中。

I was using .htaccess to rewrite everything back to my root folder but used

我使用。htaccess将所有内容重写回根文件夹,但使用了

background-image: url('../img/login_facebook.png')

in my css file. I removed the .. and the problem was solved.

在我的css文件。我删除了. .问题解决了。

#17


0  

This may be a problem with one of the extensions/plugins. Try out the incognito mode - this helped me once.

这可能是一个扩展/插件的问题。尝试隐身模式-这帮助了我一次。

#18


0  

Here is another great article on why this occurs: https://www.nczonline.net/blog/2009/11/30/empty-image-src-can-destroy-your-site/

下面是另一篇关于为什么会发生这种情况的文章:https://www.nczonline.net/blog/2009/11/30/empty-image-src-can-销毁你的网站/

I was getting the same error using Chrome in an ASP.NET site. I was getting the page life-cycle firing again with IsPostBack set to False.

我在ASP中使用Chrome的时候也犯了同样的错误。网的网站。我在IsPostBack设置为False的情况下再次启动页面生命周期。

This caused all sorts of issues for me.

这给我带来了各种各样的问题。

#19


-2  

I believe it is just how Google Chrome works. I put some code on my index page to write to a file with the file name that was loaded, and every time I load the page (using refresh or a new window) it puts 2 results in the file.

我相信这就是谷歌Chrome的工作原理。我在我的索引页上放了一些代码,以写入一个已加载文件名的文件,每次我加载页面(使用refresh或一个新窗口),它都会在文件中放入两个结果。

EDIT: I renamed my index file to test.php and ran it again. This time it only had one result. This problem is pissing me off.

编辑:我将索引文件重新命名为test。然后再次运行。这次只有一个结果。这个问题让我很生气。

EDIT: I renamed my file back to index.php and ran it. Same problem. Then I renamed my .htaccess (for mod_rewrite) to htaccess so it wouldn't be parsed and the problem is gone. After I found this out, I disabled url rewriting in the .htaccess file and the problem was still gone (finally). I did one more test (if people are still reading this crap) and found that google loads the page twice when you redirect from the .htaccess file. I found a little workaround that seems to fix the problem.

编辑:我将文件重命名为索引。php和跑。同样的问题。然后我将.htaccess(用于mod_rewrite)重命名为htaccess,这样就不会解析它,问题也就解决了。在我发现这个之后,我禁用了.htaccess文件中的url重写,问题仍然没有解决(最后)。我又做了一个测试(如果人们还在读这个垃圾),发现当你从。htaccess文件重定向时,谷歌会加载两次页面。我找到了一个解决问题的方法。

Not sure if this applies to asp.net. I only know php coding and apache servers.

不确定这是否适用于asp.net。我只知道php编码和apache服务器。