472,973 Members | 2,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,973 software developers and data experts.

Application Active users and global.asax

Hi,
Any idea to get the -REAL- number of active users -WITHOUT- this kind of
code ?

----------------------------------------------------------------------------
---------
Sub Session_OnStart
Application.Lock
Application("Active")=Application("Active")+1
Application.Unlock
End Sub

Sub Session_OnEnd
Application.Lock
Application("Active")=Application("Active")-1
Application.Unlock
End Sub
----------------------------------------------------------------------------
---------

This is definitively a wrong way, because some disconnected clients fail to
fire session_onend, which keep the number of active users abnormally high.

I'd like to find something acting like the "current users counter" as seen
in perfmon.
Any help appreciated (really) :)

Thanks in advance,
J.Philippe
Nov 19 '05 #1
5 1963
You can get a third party control to help you, or write a handler. Either
way, the code is going to look similar to what you posted.

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
--------------------------------------------------
"Homer J. Simpson" <no*@home.fr> wrote in message
news:d4***********@feed.teaser.net...
Hi,
Any idea to get the -REAL- number of active users -WITHOUT- this kind of
code ?

----------------------------------------------------------------------------
---------
Sub Session_OnStart
Application.Lock
Application("Active")=Application("Active")+1
Application.Unlock
End Sub

Sub Session_OnEnd
Application.Lock
Application("Active")=Application("Active")-1
Application.Unlock
End Sub
----------------------------------------------------------------------------
---------

This is definitively a wrong way, because some disconnected clients fail
to
fire session_onend, which keep the number of active users abnormally high.

I'd like to find something acting like the "current users counter" as seen
in perfmon.
Any help appreciated (really) :)

Thanks in advance,
J.Philippe

Nov 19 '05 #2
Well the code suits what u are looking for..
My advice is just try setting ur session that will suit you in IIS.So
that ur number of active users won't be abnormally high.
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3
Patrick,

SesionTimout is set to 1Mn in my applications. What else can i tune to track
"dsconnections" ?

Thanks,
J.Ph.

"Patrick Olurotimi Ige" <na********@hotmail.com> a écrit dans le message de
news:ud**************@TK2MSFTNGP12.phx.gbl...
Well the code suits what u are looking for..
My advice is just try setting ur session that will suit you in IIS.So
that ur number of active users won't be abnormally high.
Patrick

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #4
Homer what do u have set in Web.Config?
Not quiet sure which one overrides but i think Web.Config overrides IIS.
Hope that helps
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #5
Patrick,
Thanks for you patience !

Session.Timeout is now set to 5 Mn in each global.asax.
Here's a sample web.config and global.asax
----------------------------------------------------------------------------
-----
*********** global.asax *************
<%@ Import Namespace="System.Web.mail" %>
<SCRIPT LANGUAGE="VB" RUNAT="Server">

'Exécuté chaque fois qu'un nouvel user se connecte
Sub Session_Start
Dim iiNbActiveUsers As Integer
Dim isGazette As String

iiNbActiveUsers = Application("ApplicationUsers")
iiNbActiveUsers = iiNbActiveUsers + 1
If iiNbActiveUsers <= 0 Then
iiNbActiveUsers = 1
End If
Application.Lock
Application("ApplicationUsers") = iiNbActiveUsers
Application.Unlock

Session.Timeout = 5
End Sub

'Exécuté chaque fois qu'un nouvel user se déconnecte ou part en timeout
Sub Session_End
Dim iiNbActiveUsers as Integer

iiNbActiveUsers = Application("ApplicationUsers")
iiNbActiveUsers = iiNbActiveUsers - 1
If iiNbActiveUsers < 0 then
iiNbActiveUsers = 0
End If

Application.Lock
Application("ApplicationUsers") = iiNbActiveUsers
Application.Unlock
End Sub

'Exécuté à chaque redémarrage de l'application (ou du serveur)
Sub Application_Start
Dim isServerStartDate as String

isServerStartDate = FormatDateTime(Now(),1) & " à " &
FormatDateTime(Now(),4)

Application.Lock
Application("ApplicationStartDate") = isServerStartDate
Application("ApplicationUsers") = 0
Application.Unlock
End Sub

'Exécuté à chaque arrêt de l'application (ou du serveur) sauf en cas de
crash
Sub Application_End
Application.Lock
Application("ApplicationUsers") = 0
Application.Unlock
End Sub

Sub Application_BeginRequest(Sender As Object, E As EventArgs)
End Sub

Sub Application_EndRequest(Sender As Object, E As EventArgs)
End Sub

Sub Application_Error(Sender As Object, E As EventArgs)
Dim isErrorText As String
Dim isUser As String
Dim iiIndex As Integer
Dim ioMailMessage As MailMessage
Dim ioException As Exception

ioException = Server.GetLastError().GetBaseException()

isErrortext = ""
isErrorText = isErrortext & "<b>Serveur :</b> " & Server.MachineName() &
"<br/>"
isErrorText = isErrortext & "<b>Page : </b>" & Request.Path & "<br/>"
isErrorText = isErrortext & "<b>Message :</b> " & ioException.Message &
"<br/>"
isErrorText = isErrortext & "<b>Source :</b> " & ioException.Source &
"<br/>"
isErrorText = isErrortext & "<b>Stack :</b> " & ioException.StackTrace &
"<br/>"

'--------- Gestion des messages SMTP -----------------------
isUser = Request.ServerVariables("AUTH_USER")
iiIndex = Instr(isUser,"\")
If iiIndex <> 0 Then
isUser = Mid(isUser,iiIndex+1)
End If
ioMailMessage = New MailMessage()
ioMailMessage.From = isUser
ioMailMessage.To =
ConfigurationSettings.AppSettings("SiteAdministrat or")
ioMailMessage.Subject = "Erreur sur l'application " & chr(34) &
ConfigurationSettings.AppSettings("SiteName") & chr(34)
ioMailMessage.body = isErrorText
ioMailMessage.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer="SMTPSERVER"
SmtpMail.Send(ioMailMessage)
ioMailMessage = Nothing
'------------------------------------------------------------

'On force un GC.Collect()
GC.Collect()
End Sub
</SCRIPT>

*********** web.config *************
<?xml version="1.0" encoding="windows-1252"?>
<configuration>
<appSettings>
<add key="SiteName" value="Comite du medicament et des dispositifs
medicaux steriles"/>
<add key="SiteAdministrator" value="webmaster@intranet" />
<add key="ActiveSite" value="1"/>
<add key="SiteRoot" value="/COMEDIMS"/>
<add key="SiteDatabase" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\InetPub\WWWRoot\COMEDIMS\_database\site. mdb;"/>
<add key="UserDatabase" value=""/>
<add key="CookieName" value="COMEDIMS :: Preferences"/>
<add key="CurrentMessage" value="15-10-2003"/>
</appSettings>
<system.web>
<authentication mode="Windows"/>
<authorization>
<allow users="*"/>
</authorization>
<customErrors mode="Off"/>
<compilation debug="true">
<assemblies>
<add
assembly="System.DirectoryServices,Version=1.0.330 0.0,Culture=neutral,Public
KeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
</system.web>
</configuration>
----------------------------------------------------------------------------
-----

I still can't figure why, even after setting timeout to 5 mn, session_onend
is not fired.
This keeps [Application("ApplicationUsers")] abnormally high. Any idea why ?

Thanks in davance,
J.Philippe
Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike Owen | last post by:
Hi, I have just used the import Wizard to import a VS 2003 app to VS 2005. I have a lot of work to do to enable it to compile successfully with all the errors and warnings it gave me, but as a...
5
by: John Christensen | last post by:
I'm currently having an issue while trying to deploy a new ASP.NET application from my personal machine to our development web server. After I copy the folder over and create an IIS application in...
4
by: BB | last post by:
Hello all, I might be missing something here, but am trying to understand the difference between using application-level variables--i.e. Application("MyVar")--and global variables--i.e. public...
5
by: Leon | last post by:
Is there a way I can create a thread at application level that running all the time along with application exists? I have tried to do the above thing, and I found for some reason, the thread only...
2
by: Lenn | last post by:
Hello, This requirement might seem strange to someone out there, but here it's We need to make sure only certain number of users can be logged in the site at the same time. Is there any way to...
6
by: jim | last post by:
Hi All, I like to know the life cycle of an ASP .NET Application( incudieng server application, such as .NET Web Service). That means from initialization to fully running and how to reboot it or...
1
by: Goober | last post by:
I converted a website that was done in ASP to dotnet, and brought over a number of items, some of which don't appear to work in the same way on dotnet as they did on ASP. One of them is an...
16
by: Fernando Arámburu | last post by:
Hi , it´s me again. I will take another way because yesterday I make a question and, probably I didn´t make myself clear so you didn´t understand my question. I want to know if there is any...
8
by: Vishwanathan Raman | last post by:
Hi I have a declared a static DataSet object SOBJ in Global.asax.I also have a localy defined DataSet LSOBJ in Global.asax which I am storing in Application State.Is there any technical...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.