I know there are many developers do not like Internet Explorer but still we need to provide support for it because of the popularity/demand. One of main reason of the popularity is probably because it is the default browser of the giant Microsoft Windows Operating System. However- we will discuss on a very interesting problem (Session Lost problem) of IE8 today.
We were working on a enterprise level project and found that session variables are getting reset on a specific page during page load event. Strange thing!!! The codes inside the page load event are very straight forward. All it is doing is bind some datagrids based on some session variables.
We initially assume that it might be because of buggy source code and our initial focus was the function that retrieve the value from session (e.g. session manager). Next we thought this might be a issue how internet explorer handle cache variable. However- definitely that was not a issue too. Then we got clueless!!! We started debugging using fidler, firebug, etc.
We have found that there are some server side Image Tag (<asp:Image />) in the page which do not have any source (<image src=””/>) value defined. Those images are the symbol of expand and shrink panel(+,- sign). Through Fiddler, we have found that those image tag requesting the default page (Default.aspx) of the folder and in our system, we reset few session variables in default page. This is how the session data losing. However- this is not the case for later versions of IE(IE8+) or other browsers (eg. firefox, chrome, etc). We never thought about it earlier. Thanks Fiddler for helping us to find out this!!!
The solution was very simple compare to the discovering of the actual problem. We had to set the value of the image src property (ImageURL property for <ASP:Image/> control) to “#” which solves the issue like charm.
<asp:Image ID="imgSampleCollapseExpand" runat="server" ImageUrl="#" />
However, setting any value to the image SRC property (or ASP:Image’s ImageUrl property) will fix the problem.
Always specify the image source property of the image tag. Follow the best practices!!!