Event Session_Start never raised

  • Thread starter Thread starter Oriane
  • Start date Start date
O

Oriane

Hi there,

In my global.asx.cs file, I want to count the number of sessions, and
therefore I increment en integer/counter inside the

void protected Session_Start (object sender, EventArgs args) method.

I'm sure I didn't misspelled the name of the method.

But the thing is that this method is never called. My sessionState is
"InProc". Do I miss something ?

Oriane
 
First, that should "protected void", rather that "void protected".
Second, if you add a "Global Application class" item to your project in VS,
it will create the stubs for all the application events and so, you
shouldn't even need to be writing this yourself.

Please try that and then let us know if the event handler is getting hit.

-Scott
 
First, that should "protected void", rather that "void protected".

Does that really matter, or is it simply author preference?

John
 
re:
!> I thought that it did matter

Since "protected" is a modifier, and modifiers are used to modify declarations of types
and type members, and "protected" specifies the declared accessibility of the "void" type,
I would assume that "protected void" is correct, as you point out.

I'm not a C#/C++ expert, so I will defer to any such expert that wants to settle this question.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
=========================
 
re:
!> You (and Scott) are correct.

Thanks for clearing that up and thanks for the link, Mark.

I was scratching my head regarding the question by the OP,
although my instinct told me : "everything's OK".

<g>




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
=========================
 
Scott M. said:
First, that should "protected void", rather that "void protected".
Second, if you add a "Global Application class" item to your project in
VS, it will create the stubs for all the application events and so, you
shouldn't even need to be writing this yourself.

Please try that and then let us know if the event handler is getting hit.
Of course, it was a mistake. I wrongly pasted my code !!

Sorry !
 
Hi Mark,

Mark Rae said:
In addition to Scott's advice, you need to be aware that what you're
attempting to do will tell you the number of sessions which have been
created since the application started, but will almost certainly not tell
you the number of current users of your site...
Is that what you're trying to know...?
Yes in fact, and your advice is precious to me. So the best I can do is to
use the GetNumberOfUsersOnline Asp.Net method.

Thanks a lot.

Oriane
 
Back
Top