views:

79

answers:

3

I'm causing a postback by clicking an asp:button. I end up in a breakpoint on Page_Load, where IsPostBack == true. Then, one breakpoint later, I end up in Page_Load where IsPostBack == false.

What the heck is going on? I'm trying to understand someone else's code.

+6  A: 

The first link click is a PostBack from the server and the correct behavior. It sounds like the second PostBack is triggered because of a Page.Redirect() or a Server.Transfer() back to the same page.

This is a best guess until you provide additional details.

Gavin Miller
+1. My thoughts exactly.
David Stratton
+2  A: 

Here is a blog post that may be helpful.

http://www.craigwardman.com/blog/2009/01/aspnet-multiple-page-load-problem.html

I was having the same issue because the src of one of my images was "" and that caused the page load to fire 2 times.

Avitus
+1  A: 

This sounds like 2 it could be 2 separate requests to the page - Check the IIS logs.

If not then its possibly a Server.Transfer(), or someone might be instantiating and calling the Page_Load method themselves for some reason (extremely unlikely, but easy to check by looking at the callstack)

Kragen