ASP.NET Page.OnLoad executes twice

前端 未结 5 1593
轻奢々
轻奢々 2020-12-31 19:46

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

相关标签:
5条回答
  • 2020-12-31 20:14

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

    0 讨论(0)
  • 2020-12-31 20:15

    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.

    0 讨论(0)
  • 2020-12-31 20:16

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

    0 讨论(0)
  • 2020-12-31 20:23

    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.

    0 讨论(0)
  • 2020-12-31 20:40

    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 :)

    0 讨论(0)
提交回复
热议问题