A few days ago, I was deploying a Website at work and ran into a very mysterious problem.
The problem is what I call a "Skipped Post Back" or a page double load problem. For example, if I load a page say, default.aspx in a browser and hit a submit button. The default behavior should be that when the submit button is clicked, a post back event is fired. The simplest way to see how this works is to consider the code snippet below:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Response.Write("Page Load");
}
else
{
Response.Write("Post Back");
}
}
If I run the page, I should see "Page Load" when the page is initially loaded and "Post Back" when I hit a submit button.
But what had happened was that when I deployed a website to a Windows 2003 server (.Net Framework 1.1), and when viewed with IE6 what happened really baffled me.
If I just type in the url (say http://mywebsite/default.aspx), everything works as expected. If however, I set my default page as default.aspx and omit the page in the url (e.g http://mywebsite/), when I hit the submit button, I would see a "Page Load" displayed instead of "Post Back".
At first, I thought that this was an issue with the code (the original page was more complicated then the sample illustrated above), but after reducing the page to the example I gave, it was clear that something was wrong with the combination of IE6 and .Net 1.1 on Windows 2003 Server, at least to this particular installation. As if the same code was deployed on a Windows 2000 server or simply just Windows XP, everything would work correctly. Further more, viewing the page with FireFox does not produce the erroneous behavior.
Clearly something is wrong here. While scratching my head, I noticed something very interesting: when I hit the submit button while running IE6 I would sometimes see "Post Back" briefly before "Page Load" showed up, which indicates that the page was for some reason loaded twice.
After hours of researching without any clear answer, I had to resort to the silliest code to fix the issue. Namely, i added a default page (say index.aspx) and all it does is to redirect to default.aspx. And I configure IIS so that index.aspx would be the default page if no page was supplied. This setting ensures that when default.aspx is loaded the url will contain the page itself.
Given that it works with Firefox but not IE6, I am pretty sure that this is an IE6 issue (or the particular patch level of IE6 we had at work).