Testing ASP application sessions

P

Pavils Jurjans

Hello, I have a couple of unclear questions about ASP.NET sessions:

First, I'd like to have some way to see how many sessions currently are
running on the certain application, and, possibly, have some way to peek in
the data of these sessions. If there is no such utility for IIS, perhaps
there is some API that I could use to write a standalone console .NET EXE,
that could talk to IIS (or some other relevant instance) and discover these
data?

Second, I'd like to know, if there is some way to distinguish from different
session expirations. I have a Session_End handler in the codebehind file for
global.asax, and, as by design, it is called whenever the session is about
to be finished, be it call to Session.Abandon, or just automatic session
expiration. So, I'd like to know if there is some way to tell from the
different reasons why session is being ended:
- is it a call to Abandon() method,
- is it an automatic expiration (ie user just closed the application, not
clicked 'log out' button)
- manual application stop
- perhaps code in the bin folder (or web.config file) has changed, forcing
application reload
- any other reason.

Currently I handle the difference by assigning a control value to session
variable prior to calling the Abandon method, and checking for the presence
of this variable in Session_End handler. But, it's sort of hacky way, isn't
it. Also, I see no such workaround way to check for application restart or
code changing situation.

Regards,

Pavils
 
P

Patrice

The number of sessions is exposed through performance counters.

By nature session variables are scoped to the parent session. You can't do
that from your app and I don't know if a tool is provided for doing this
(you can if using SQL Server as the session provider). Why do you want to
do that ? You could dump session variables when an error is encoutered.

A sesion doesn't expires when the browser is closed (it expired once the
server has no news from the suer druing a given period of time).

Once again it depends what is the overall goal (for example you can track
application restarts through .NET classes).

Patrice
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top