tags:

views:

175

answers:

3

I have AutoEventWireup="true" and in my code behind

protected void Page_Init(object sender, EventArgs e)
{


}

When I'm debugging the Page_Init method is getting fired twice!

Whats going on!?!

+1  A: 

You probably have some sort of redirect or ajax postback that is firing.

Chris
It was the redirect.
AJM
I shouldn't even say this, as I hate nitpicking/rep-whoring, but if my answer was the correct one, you should probably mark it as such.
Chris
+1  A: 

Do you have any code anywhere that looks something like this?

this.Init += Page_Init;

If so you are accidentally wiring the event twice. Either delete the manual event wiring or set AutoEventWireup to false.

Andrew Hare
+3  A: 

Let's make sure we cover the basics here:

Do you have any controls on your page that have server events? If so, remember that every postback re-creates the entire page. So, to handle an event means running all of the code required put the page together, including your Init and Load events.

Always two there are, no more no less. A request and a response.

Joel Coehoorn