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

So you have your website deployed in PROD ... now what ??

Posting on behalf of Usr.Web.Speed - My previous job had been to architect and develop websites for various customers. During that time my team and I have architected and developed various web applications mainly for enterprises. (But below info is not restricted to enterprises) Other than the usual development and testing tasks involved, our focus area was to abide by multiple SLAs. One of the primary SLAs was to provide the users of our websites a very low (usually subsecond) response time (or page load time). To adhere to this SLA, we did multiple activities, in code, process as well as infrastructure. These include (but not limit to) - Using best practices including (http://developer.yahoo.com/performance/rules.html) Determining the optimum number of calls to the databases, open connections, etc. Providing the fastest mechanisms to download associated content (such as stylesheets, JS files, etc. over CDN) And debugging the reason for the slowness of the websites, when ...

Theming in Whidbey using CSS

Continuing my blog titled Themes in Whidbey . I would like to mention some great points I did find out today about Whidbey featrures. How many times have you got sick of developing Sites which have themes???? I mean every page u create has to have, maybe in ASP, something like <link href="<%=Session["ThemeFile"]%>.css"/> I have been doing since a long time. Do mention if you have a simpler method of defining a variable CSS for your page!!! Whidbey simplifies this further. Now in ASP.NET, all you will have to do is Create Themes directory, if not aldready present, Create a directory for each theme required, maybe Black, Gray,etc. Dump your CSS files into this directory. in Page_PreInit method define the Theme as Page.Theme="<Theme directory Name>". Further can be made into Page.Theme=(string)Session["ThemeType"] and viola, your theme management is take care by ASP.NET When you want to change the theme, the...