Bill Brown bio photo

Bill Brown

A complicated man.

Twitter Github

The Page_Load event was firing twice—inexplicably. If I removed the explicit declaration in the code-behind class, then it fired once. That pointed clearly to two bindings, but I could not find anything in the usual haunts of global code. Nothing had changed except that we moved to .NET 2.0.

Of course, I found out that in ASP.NET 2.0 AutoEventWireup defaults to true even if no Page declaration is present. Well, that's a fine how-do-you-do! In 1.1, it defaulted to false, which made abundant sense. When migrating an application, you'd think that that would have been accounted for since it is such a potentially-disastrous change.

I mean it's one thing to have Page_Load fire twice. It's another entirely if you've got initialization stuff in OnInit or if you're doing any multicast delegation. Crazy!

Oh, so the easy fix is to change it in machine.config or Web.config by adding a autoEventWireup="false" to the pages element. Problem solved.