Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2003, 01:28 AM
Authorized User
 
Join Date: Sep 2003
Location: islamabad, pk, Pakistan.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default GLOBAL.ASA

Hello Everyone Hope ur doing fine.
I am using a file GLOBAL.ASA
-----------------------------
<script language="vbscript" runat="server">

Sub Application_OnEnd()
Application("totvisitors")=Application("visitors")
End Sub

Sub Application_OnStart
Application("visitors")=0
End Sub

Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application.UnLock
End Sub

Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock

End Sub
</script>

-----------------------------
I am displaying the No of Active users as<%response.write("Application("visitors")")%> but it is showing 1(one) user always.
Please guide me in this reghard.


Zaeem Sherazi
__________________
Zaeem Sherazi
 
Old November 3rd, 2003, 03:10 PM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How are you viewing the total number of active users that would allow you not to be one of them? Does that make sense? If you are viewing a page on the server, and therefore have started a session with the server, then of course there will be at least one user active.

Just another note on your code as well, if your goal of the Application_OnEnd() is to gather the total number of users that have visited your site between application runs, then it will not work. Since you increment and decrement Application("visitors") everytime a session starts or ends, then when the application ends, you will only get the total number of active users at the time the application was terminated. You should increment totusers every time a session starts and leave it at that, otherwise your numbers won't be accurate.

 
Old November 4th, 2003, 12:38 AM
Authorized User
 
Join Date: Sep 2003
Location: islamabad, pk, Pakistan.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default

Thanx for ur quick reply. But I am not showing the Total Visitors visited the Site. But when I show the no of active visitors sometimes it shows -1 or 1.<%=application("visitors")%> I couldn't figure it out. Plesae review it and let me now. I'll be grateful to u for this favor.

Zaeem Sherazi
 
Old November 4th, 2003, 09:13 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you make changes to your Global.asa, do you unload your site via IIS? I can see the -1 happening maybe if you installed your global.asa after the application on_start occured, but that file shouldn't run really without restarting the site...I'm grasping at straws at this point...

Like I said in my previous post though, no matter what, if you are viewing a page in the application then you have created a session and should be considered an active user. So you should always at least see a 1 for the number of active users. If this doesn't make sense let me know.

The -1 might be due to the scenario I mentioned above, but I'm not completely sure. I would try unloading the site, and stopping and starting it via IIS. This should give you a clean slate to work with as far as session and application state are concerned.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Global.asa pushpa Classic ASP Basics 19 March 9th, 2007 08:30 AM
global.asa vin_0x1 Classic ASP Components 2 July 24th, 2006 01:13 AM
Global.asa gmoney060 Classic ASP Basics 3 September 25th, 2004 09:11 AM
Global.asa madsmad ASP.NET 1.0 and 1.1 Basics 1 August 17th, 2003 07:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.