most unbelievable phenomenon

G

Guest

Here's what happening.
On 'page1.aspx' I redirect to 'page2.aspx':
Response.Redirect("page2.aspx", true);

On 'page2.aspx' I'm redirecting to 'page3.aspx':
Response.Redirect("page3.aspx", true);

When page 'page3.aspx' 'Page_Load' completes it
also calls 'Page_Load' of page 'page1.aspx'.(bizzare)
Please understand that I in no way am calling it.

What is going on?!!!!!!!

I found all that while debugging with breakpoints in all form's 'Page_Load'
events.
By the way, 'page2.aspx' never calls 'page1.aspx', only 'page3.aspx'.

Any insight?
Thanks,
Oleg
 
K

Kevin Spencer

Redirecting and stopping execution are 2 different things. That is,
Response.Redirect sends an HTTP Redirect message to the client. It doesn't
say "Stop program execution here." Page 1's code isn't being called from
anything. It's just continuing.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 
E

Edwin Knoppert

Huh?
I was under the impression after redirect nothing get's executed, ASP.NET
aborts.
Also like when using Response.end
Will have to verify that again.
 
K

Kevin Spencer

My mistake, Edwin. It does end execution, under normal circumstances. I was
thinking about the "EndResponse" parameter. However, upon further research,
I saw that it can raise an HttpException if it is called after the Http
Headers have been sent to the client. I'm not sure whether or not this might
cause the method to be interrupted and not call Response.End. If so, that
might be the cause of the issue.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 
K

KJ

This can also happen if Page3 inherits from Page1, e.g., public class
Page3 : Page1 (C#).
 
K

KJ

This can also happen if Page3 inherits from Page1, e.g., public class
Page3 : Page1 (C#).
 
K

KJ

This can also happen if Page3 inherits from Page1, e.g., public class
Page3 : Page1 (C#).
 
G

Guest

KJ is probably the closest to the truth here.
Although I checked for inheretance and it's not the case.
They both inherit from the same page.
Even with inheritance, I would expect Page1's 'Page_Load' run before
Page3 'Page_Load'. But it happens vise versa.
I'll try to reboot and update you on the status tomorrow.
Oleg
 
D

Damien

Kevin said:
My mistake, Edwin. It does end execution, under normal circumstances. I was
thinking about the "EndResponse" parameter. However, upon further research,
I saw that it can raise an HttpException if it is called after the Http
Headers have been sent to the client. I'm not sure whether or not this might
cause the method to be interrupted and not call Response.End. If so, that
might be the cause of the issue.
Or if there is a too general exception handler wrapping the
Response.Redirect, then execution will continue into the catch and any
code thereafter.

Damien
 
G

Guest

the thing is, it even calls Page1 even on the postback of the Page3.
How is that possible?
Oleg
 
G

Guest

I finally found an answer or solution rather to my problem!!!!

In my application Properties -> Documents Page1.aspx was
on the top of the list. So I removed it from there list.
No more problems!!!!!
Go figure.

Oleg
 
K

KJ

Postbacks still trigger the page events for inherited classes (pages).
But you state that you are not inheriting, so perhaps that's not a
response relevant to the question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top