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?
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.
You probably have some sort of redirect or ajax postback that is firing.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With