page loads twice in Google chrome

Viewed 35183

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

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

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.

3rd edit: It happens ONLY at the refresh!

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

22 Answers

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?

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

Thanks to this posting I checked my CSS sheet.

I removed this line:

body { background-image: url(); }

That was the problem

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.

Perhaps it applies to all elements with an empty src.

Base on Johann's reply, I check and disable each extension in google chrome and discover the flash extension cause my browser reload twice. After remove it, the problem is solved!!

In my case it was this <link rel="shortcut icon" href="#" /> tag in the head of my index.html file:

<html lang="en">
  <head>
  ...
  <link rel="shortcut icon" href="#" />
  ...
  </head>
  ...
</html>

I just removed that line and problem solved.

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?

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.

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.

I encountered a similar problem with PHP and 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

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

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.

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

It also doesnt like empty href's

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

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.

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.

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.

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

Related