Adrian Zanescu
Adrian Zanescu

Reputation: 8008

ASP.NET Page.OnLoad executes twice

Anyone have any idea when and why Page.OnLoad() executes twice in the ASP.NET lifecicle?

Upvotes: 7

Views: 2455

Answers (5)

Răzvan Flavius Panda
Răzvan Flavius Panda

Reputation: 22106

Another possibility is that Visual Studio browser link is enabled. To figure out what caused the issue you can inspect the Request object.

Upvotes: 1

Dominic
Dominic

Reputation: 712

Do you have any controls with AutoPostBack set to true ? That will cause the Page object to be recreated and therefore the PageLoad method will execute again.

Upvotes: 0

axel_c
axel_c

Reputation: 6796

Make sure you don't have any tags like <img src="#"> or <img src="">, that makes IIS load the page twice. It's a classic.

Upvotes: 2

Mehrdad Afshari
Mehrdad Afshari

Reputation: 421968

Do you have AutoEventWireUp set to true and also attaching an event handler in code? This is a common reason.

Upvotes: 1

leppie
leppie

Reputation: 117220

Do you have a an IMAGE element with a blank string for the URL on that page?

This one has caught so many people before :)

Upvotes: 8

Related Questions