Open Bug 576595 Opened 12 years ago Updated 3 years ago

Page Load event fires twice if any asp:image object does not have a specified img src


(Core :: DOM: Core & HTML, defect, P5)

Windows XP





(Reporter: patgiguere, Unassigned)


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20100625 Firefox/3.6.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20100625 Firefox/3.6.6

I want to leave an ASP image object's img src property empty so that it can be set dynamically after the page initially loads.  I have found that when I do this, my page load event fires twice (postback is false on both events).  I'm not sure if this is a bug or intended behavior, but it is causing performance issues for my page since a lot of expensive code is run on its initial load. This does not appear to me to be a bug in .NET since the issue does not occur on internet explorer.

Reproducible: Always

Steps to Reproduce:
1.Build an ASP.NET page
2.Put an asp:image on it and set 'img src=""'
3.load page and notice the page_load event fires twice
Actual Results:  
page_load event fires twice with no post back

Expected Results:  
page_load event should only fire once without postback

I can't think of a work around since post back is false both times the event is fired.
> I want to leave an ASP image object's img src property empty

So you do <img src="">?  Per the URI specs, that means "load the URI of the current page as an image".

The right way to do what you're trying to do is to not set the src attribute at all.

We ended up having to violate the spec here because of broken sites like yours...

That said, said spec violation was checked in back in the Firefox 3.5 timeframe.  See bug 444931.  So I don't see how you could possibly be hitting the problem in 3.6.6.

Can you point me to a page that shows the behavior?

In any case, this has nothing to do with forms...
Component: HTML: Form Submission → DOM
QA Contact: form-submission → general
Simply having <img src=""> on a webpage will cause Firefox to do a second GET request for the current page. As a web developer this is surprising (and can cause server performance issues). This same issue exists in Google Chrome and Safari, but not Opera (can't test IE).

A workaround is to leave out the src tag. eg: <img>
This works perfectly fine and the image source can be added later in JavaScript.

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b6) Gecko/20100101 Firefox/4.0b6
The build you mention in comment 2 should not be loading <img src=""> unless your document's base URI doesn't match the document URI...  Note that per the HTML4 and URI specs the old behavior was correct, but too many people seem to think that "" is somehow special as a URI (it's not; it's just a relative URI that resolves to exactly the base URI).

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.