IE Image Bug = Website Performance Hit

While troubleshooting a site I'm developing, I noticed that a page was double posting.  After a little brute force diagnostics, (comment everything out, bring things in one-at-a-time), I was able to isolate the issue.

My company has a couple of ImageButtons that are wired up as hover buttons.  We have a control that you set the on & off images on and it does the rest.  For some reason (Murphy's Law I suppose), we weren't sending out the ImageButton's ImageUrl as the off image.  We just let the startup javascript assign that client side.  This resulted in an input type=image form field with an empty src attribute being sent to the client.  That seems benign right?  Well it isn't...

If you have on your page one image field with a valid src attribute and another with no src attribute, IE interepts the src of the missing attribute to be the url of the current page and then IE will proceed to request the current page again in hopes of displaying an image for the missing scr attribute.  Ouch right?

This means that if you have any control, image button, asp:image, etc on you site that is sending out src="", which you might not, IE will perform a double post to your page.  Yes a double post and all form fields are sent, it is a full blown duplicate request.  This means performance * .5...

This is easily tested in your ASP.NET application.  All you need is a page with the following markup and a wired up Page_Load with a breakpoint on string Foo = "Bar";.  Run the debugger an enjoy...

<img src="" /><img src="valid.jpg" />

Disclamier:  I haven't tested to see if the non-blank src must be valid...  When I say IE I have only tested IE7 and it fails.  I did test Google Chrome and it did not create a duplicate request.

I realize that this might not be a big deal because I'm the only person out there sending out empty src attributes, but I thought I'd share the find.

4 Comments

Comments have been disabled for this content.