Skip to main content

What an empty src translates to!!!!

Yesternight, while trying to debug a bug logged against our ASP.NET code, we crashed into a wierd problem.

The scenario of the problem was:
- We had an ASP.NET page. When opened in IE, the page seemed to be executing fine. But loading this in FireFox (both versions 2 and 3b2), resulted in the ASP.NET Page lifecycle (OnInit,etc.etc.) being called twice.

We then used tcptrace (a tool similar to Fiddler. We were unable to get Fiddler working for FireFox, even after using the Pac file). We found that every postback resulted in the page being requested twice. One was a POST request (PostBack). The other was a GET request. Our immediate assumption was that ajaxcontroltoolkit must be trying to do some GET request only for FireFox browsers. Further analsysis cancelled this out, 'cos we realized that even IE was sending a request.

But there was a difference:
- IE was sending the request to the directory hosting the page
- FireFox was sending the request to the page to which the PostBack had to occur.

Then we misassumed that we had some JavaScript requesting for the same page again. But what irritated us was as to why IE and FireFox would behave differently for this JavaScript code? SO we had to rule out the option of JavaScript.

Taking a break at this point of time, helped.... And thought processes kicked in.. We put 2 plus 2 together and luckily hit on the correct number 4....

We opened the HTML source of the page, and started checking the href and src for every element on the page. We were unsure what we searching for, but for some reason were pretty sure that the problem was with SRC or HREF attribute of some tag.We stumbled on an img tag with a src="" (empty string). This looked pretty suspicious, and so one of us immediately created a sample page. Having nothing other than an img with src="". And managed to simulate the exact same problem.

So returning back to our original ASP.NET code, we found the location where the code was setting the ImageUrl to string.Empty, and changed it to "#". (Before you shout at me for stupiditiy, we are actually setting the image thru CSS background). And finally the page started behaving as all good ASP.NET pages should!!!

So 6 hours of debugging, taught us one more difference between the behaviours of FireFox and IE.
- "In case we host a page http://server/Directory/Page, and in the Page we have a src or href attribute with an empty string, FireFox will place a GET request for Page and IE will request for Directory"!!!!

Life in the web world is wierd, isn't it!!!!

Comments

Popular posts from this blog

The fight is in the open

Been busy lately and so have not managed to post for quite long. But I just had to post this. This post is dedicated to all persons who dont know anything about the fight between MS and Google: Check out the links starting from: http://news.zdnet.com/2100-9588_22-5875433.html?tag=nl.e589 There are more links as you get thru the article. Be sure to read those too. And just as a side-note: Check out " Atlas ". These are client side and server side components, which easily (??) enable you to make Web calls. This is done by encapsulating AJAX. (please dont insult by telling me that you dont know what that is).

Finally decided

I have been having these various itch since quite some time. Both about what i am doing here (where i work) and what am i meant to do. Finally, i have decided "I need a job change". I guess IT services industry was never meant to be the right industry for me. Don't get me wrong there, it's not that i wanna quit because i am not getting any interesting work, it's just that I have ideas about life which does not match with what my company is doing. (As amatter of fact, they have some really beautiful concepts which are great to work on). But i have believed web to be the future and now i have started realising that personal dreams do become quite a pain in the neck, when they are ignoired. Huh.... now that i put it on a log, i feel much better. Back to work...

News Feature

Enough of idle minds' posts. Instead got down to the engines of coding and coded the "Top News Stories", available on the right :D, on the side bar. Initially on load of the page, i was planning to show all the current top stories, accessing it from other sites. But, IE seems to have some security restrictions on a web page accessing resources of other web sites. Ok, i think that's what it is. So it pops up some security message. So i have shifted over to using a textbox and a "Go" button. On the click of the "Go" all the news as per the xml feed in the text box will be displayed. Go ahead and try it, but remember to click "Yes" on the security warning. Anyway for the knowledgeable. On click of the "Go!!!" it uses XmlHttpRequest , retrieves the XML feed from the site mentioned in the text box and displays it in "user friendly" format.