473,500 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1976
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
512
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
1396
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
3520
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
2043
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
1782
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
2618
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
1866
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
3128
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
4844
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...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.