Forum Moderators: open

Message Too Old, No Replies

Session_Start firing twice

         

Jimmy Turnip

10:14 am on Nov 7, 2005 (gmt 0)

10+ Year Member



I am having a problem with my application with it firing the session_start event in the global twice.

I am not using frames and there is no abandoning of the session further down the page.

I know the event is firing twice because I put an i += 1 in the event and response.write(i)

I've asked this question on a couple of other forums with no replies at all. It's not that i'm looking for a direct answer to my question, but more of a method for finding out why this could be happening.

Anyone got any ideas?

tetra

1:23 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



it seems that the question couldn't be caused by

i+=1 and response.write(i)

the session is used to track the web browser,
i think the question may be caused by other pages that inclue session operation.
suggest you checking other pages

Jimmy Turnip

4:09 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



Hi tetra thanks for trying to help.

Are you saying that it could be caused by trying to access the session on another part of the page before the session_start event is fired? I'll have a check anyway.

Anyone else?

emsaw

1:33 am on Nov 8, 2005 (gmt 0)

10+ Year Member



One thing to check:

make sure that for all of your pages that the AutoEventWireup page directive is not set to true .

Gave me fits when it happened to me :P

HTH,

mark

Jimmy Turnip

9:49 am on Nov 8, 2005 (gmt 0)

10+ Year Member



Thank you so much emsaw - and thanks to webmaster world, the only forum where someone has got back to me with the answer and it's not even a dedicated .net forum.

It was so frustrating that after I built the site tracking code, I left it until I'd finished the rest of the site to work out why it was firing twice.

I can't believe it was such a simple, but really obscure thing. Have you got any idea why this happens?

I was assuming that my subs like "Handles MyBase.Load" (working in VB) would no longer work but they do. What exactly are the pages AutoEventWired to then?

emsaw

7:32 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



My understanding of it is this:
If you have AutoEventWireup set to true, the compiler looks for common functions and events, like _Load, _ItemDataBound, etc and 'automatically' links those to the appropriate events, so by also defining the sub with a 'Handles' assertion, you are essentially calling the event twice, so either you should use AutoEventWireup, or do all of your own 'Handles'.

-Mark

Jimmy Turnip

12:17 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



I see. I remember I had a problem with my Page_Load event of a UserControl on another site firing twice and I got round that by just renaming the sub <Control Name>_Load. I suppose that must've been the same problem.

Thanks again for your help.