Session_Start/End Question

  • Thread starter Thread starter Jeff S
  • Start date Start date
J

Jeff S

My intent is to write some information to a database when a new session of
my application begins. The code that writes to the database works great -
however the Session_Start procedure (in Global.asax.cs) is run for each page
requested. Specifically, what I'm observing is that when I start the
application via VS.NET 2003 (default.aspx), and then immediately navigate
via the browser to another page, and then immediately to another, I get one
entry in the database for each page opened. Stepping through at runtime
verifies that Session_Start is being called when each successive page is
opened. While I may be misunderstanding exectly when a session starts and
stops, I doubt a new session is supposed to start for every page requested.

I would appreciate it if someone could explain what ASP.NET considers to be
a session - when it starts, when it stops, etc.

Thanks.
 
A session begins when a user requests a page for the first
time from your application and ends either when your
application explicitly closes the session or when the
session times out.

Normally, the session will not timeout immediately. Do you
have any code deliberately close the session? such as
Session.Abandon()

Bin Song, MCP
 
Nope - no code to explicitly abandon the session, and no apparent reason the
sessions should time out immediately. Does the fact that I'm developing and
testing on the same machine have any relevance here?

I read the fine manual and understand what you pointed out - that "a session
begins when a user requests a page for the first time...". All the books
and online help say the same thing - that's why I'm a bit confused on this
one.

Jeff
 
Back
Top