How to count the active ASP.NET Sessions (SQL Server)?

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9lU2Vw?=, Oct 9, 2006.

  1. Hello,
    I know that when the SessionState is set to SQL Server (ASP.NET 1.1) these
    counters in PerfMon are not valued:
    - Sessions Abandoned
    - Sessions Active
    - Sessions Timed Out
    - Sessions Total
    Is there another way to get these counters (especially "Sessions Active")
    when the SessionState is set to SQL Server?
    Thanks in advance!
    Joe

    --
     
    =?Utf-8?B?Sm9lU2Vw?=, Oct 9, 2006
    #1
    1. Advertising

  2. Joe,

    Performance counters are only valid for In-Process session state management.
    To count active sessions in SQLServer mode you need to create a stored
    procedure in the tempdb database that returns the counter:

    DECLARE @Now DATETIME

    SELECT COUNT(*) AS SessionCount
    FROM ASPStateTempSessions
    WHERE (Expires < @Now)


    hope this helps
    --
    Milosz Skalecki
    MCP, MCAD


    "JoeSep" wrote:

    > Hello,
    > I know that when the SessionState is set to SQL Server (ASP.NET 1.1) these
    > counters in PerfMon are not valued:
    > - Sessions Abandoned
    > - Sessions Active
    > - Sessions Timed Out
    > - Sessions Total
    > Is there another way to get these counters (especially "Sessions Active")
    > when the SessionState is set to SQL Server?
    > Thanks in advance!
    > Joe
    >
    > --
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=, Oct 9, 2006
    #2
    1. Advertising

  3. Milosz,
    Yes, thank you very much!

    --
    "Milosz Skalecki" wrote:

    > Joe,
    >
    > Performance counters are only valid for In-Process session state management.
    > To count active sessions in SQLServer mode you need to create a stored
    > procedure in the tempdb database that returns the counter:
    >
    > DECLARE @Now DATETIME
    >
    > SELECT COUNT(*) AS SessionCount
    > FROM ASPStateTempSessions
    > WHERE (Expires < @Now)
    >
    >
    > hope this helps
    > --
    > Milosz Skalecki
    > MCP, MCAD
    >
    >
    > "JoeSep" wrote:
    >
    > > Hello,
    > > I know that when the SessionState is set to SQL Server (ASP.NET 1.1) these
    > > counters in PerfMon are not valued:
    > > - Sessions Abandoned
    > > - Sessions Active
    > > - Sessions Timed Out
    > > - Sessions Total
    > > Is there another way to get these counters (especially "Sessions Active")
    > > when the SessionState is set to SQL Server?
    > > Thanks in advance!
    > > Joe
    > >
    > > --
     
    =?Utf-8?B?Sm9lU2Vw?=, Oct 9, 2006
    #3
  4. =?Utf-8?B?Sm9lU2Vw?=

    Eirikh Guest

    Milosz Skalecki and others,

    I would rather go:

    SELECT COUNT(*) AS SessionCount
    FROM [ASPStateTempSessions]
    WHERE ([Expires] > GETDATE())

    GETDATE() instead of a variable that's not really needed (and only
    declared?) and I changed the < to > to actually get all sessions that expires
    in the future, and not the ones that have already expired...


    "Milosz Skalecki" wrote:

    > Joe,
    >
    > Performance counters are only valid for In-Process session state management.
    > To count active sessions in SQLServer mode you need to create a stored
    > procedure in the tempdb database that returns the counter:
    >
    > DECLARE @Now DATETIME
    >
    > SELECT COUNT(*) AS SessionCount
    > FROM ASPStateTempSessions
    > WHERE (Expires < @Now)
    >
    >
    > hope this helps
    > --
    > Milosz Skalecki
    > MCP, MCAD
    >
    >
    > "JoeSep" wrote:
    >
    > > Hello,
    > > I know that when the SessionState is set to SQL Server (ASP.NET 1.1) these
    > > counters in PerfMon are not valued:
    > > - Sessions Abandoned
    > > - Sessions Active
    > > - Sessions Timed Out
    > > - Sessions Total
    > > Is there another way to get these counters (especially "Sessions Active")
    > > when the SessionState is set to SQL Server?
    > > Thanks in advance!
    > > Joe
    > >
    > > --
     
    Eirikh, Sep 7, 2010
    #4
  5. =?Utf-8?B?Sm9lU2Vw?=

    Eirikh Guest

    I actually ended up with this:

    SELECT COUNT(*) AS SessionCount FROM ASPStateTempSessions WHERE
    DATEADD(mi,15,LockDateLocal) > CURRENT_TIMESTAMP

    Users active in the last 15 minutes ...

    "Eirikh" wrote:

    > Milosz Skalecki and others,
    >
    > I would rather go:
    >
    > SELECT COUNT(*) AS SessionCount
    > FROM [ASPStateTempSessions]
    > WHERE ([Expires] > GETDATE())
    >
    > GETDATE() instead of a variable that's not really needed (and only
    > declared?) and I changed the < to > to actually get all sessions that expires
    > in the future, and not the ones that have already expired...
    >
    >
    > "Milosz Skalecki" wrote:
    >
    > > Joe,
    > >
    > > Performance counters are only valid for In-Process session state management.
    > > To count active sessions in SQLServer mode you need to create a stored
    > > procedure in the tempdb database that returns the counter:
    > >
    > > DECLARE @Now DATETIME
    > >
    > > SELECT COUNT(*) AS SessionCount
    > > FROM ASPStateTempSessions
    > > WHERE (Expires < @Now)
    > >
    > >
    > > hope this helps
    > > --
    > > Milosz Skalecki
    > > MCP, MCAD
    > >
    > >
    > > "JoeSep" wrote:
    > >
    > > > Hello,
    > > > I know that when the SessionState is set to SQL Server (ASP.NET 1.1) these
    > > > counters in PerfMon are not valued:
    > > > - Sessions Abandoned
    > > > - Sessions Active
    > > > - Sessions Timed Out
    > > > - Sessions Total
    > > > Is there another way to get these counters (especially "Sessions Active")
    > > > when the SessionState is set to SQL Server?
    > > > Thanks in advance!
    > > > Joe
    > > >
    > > > --
     
    Eirikh, Sep 7, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vikram Sinha
    Replies:
    0
    Views:
    431
    Vikram Sinha
    Jul 17, 2003
  2. Ken Cox [Microsoft MVP]

    Re: Relationship between IIS Sessions and ASP.NET Sessions?

    Ken Cox [Microsoft MVP], Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,373
    Luther Miller
    Aug 8, 2003
  3. =?Utf-8?B?TGVubg==?=
    Replies:
    2
    Views:
    866
    =?Utf-8?B?TGVvbiBXZWxpY2tp?=
    Oct 19, 2004
  4. whidbeywave
    Replies:
    0
    Views:
    685
    whidbeywave
    Oct 27, 2005
  5. Krish...........
    Replies:
    2
    Views:
    1,158
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 16, 2007
Loading...

Share This Page