Print Page | Close Window

Asp Question

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6933
Printed Date: 31 March 2026 at 12:07pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Asp Question
Posted By: Tegwin
Subject: Asp Question
Date Posted: 02 November 2003 at 4:01pm
Ok, I am very new to asp and still trying to learn so forgive me if the question sounds dumb or trivial..

I have been following in a book, on how to make a simple web counter, they suggested to use a global.asa file. which has the following information in it

<Script.Language="vbscript" runat="server">

sub Application_OnStart
Application("count")=1
end sub

Sub Application_OnEnd
end sub

sub Session_OnStart
Application.lock

Application("count")=Application("count") + 1

Application.unlock
end sub

sub Session_onEnd
end Sub

</script>




then I have created a file called visitors.asp with the following code.



<%
   Response.Write("Number of people visited so far")
   Response.Write(application("count"))
%>



I have both these files copied into the same path, but when I run the visitors.asp  it only displays " Number of people visited so far" , but not the number..

What am I doing wrong ?






-------------
If you dont want my peaches, dont shake my tree



Replies:
Posted By: michael
Date Posted: 02 November 2003 at 7:05pm
the global.asa MUST be in the root of your site (or virtual dir) and if you have a host he must also support global.asa's

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Tegwin
Date Posted: 03 November 2003 at 1:17am
Michael, I am doing this on my own server.

The global.asa is in the  the virtutal directory. Basically I have a Virtual Dir called count, which is pointing to d:\webs\count and that is where the global.asa resides and also the visitors.asp and it does not work.





-------------
If you dont want my peaches, dont shake my tree


Posted By: Mart
Date Posted: 03 November 2003 at 2:50am

<Script.Language="vbscript" runat="server"> try removing the '.' between script and language.

Mart.



Posted By: Mart
Date Posted: 03 November 2003 at 2:53am

But it looks as if your using golbal.asa for a page counter. You cant do that because application reset when the server restarts etc. But you can do a 'active visitor' counter like on the bottom right of this page.

Mart.



Posted By: Tegwin
Date Posted: 03 November 2003 at 10:43am
Mart, thanks for that, Yes it is for a page counter, I have found this very script in a book on learning ASP, so one would hope the authors know that a global.asa cant be used for this purpose... oh well perhaps not.

Do you know where I can get an example of an "active visitor" script as on this page.



-------------
If you dont want my peaches, dont shake my tree


Posted By: Mart
Date Posted: 03 November 2003 at 11:20am

http://asptutorial.info/learn/global_asa.asp - http://asptutorial.info/learn/global_asa.asp  at the bottom of the page.

Mart.



Posted By: Tegwin
Date Posted: 03 November 2003 at 12:23pm
Ok i think something must be wrong here now. I have copied and pasted the code, exactly like in the example above at your link http://asptutorial.info/learn/global_asa.asp - http://asptutorial.info/learn/global_asa.asp

global asa


<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Sub Application_OnStart
application("activevisitors")=0
End Sub

Sub Application_OnEnd
End Sub

Sub Session_OnStart
application.lock
application("activevisitors")=application("activevisitors" )+1
application.unlock
End Sub

Sub Session_OnEnd
application.lock
application("activevisitors")=application("activevisitors" )-1
application.unlock
End Sub

</SCRIPT>



and visitors.asp



<HTML>
<BODY>

There are  <% =application("activevisitors") %> active visitors.

</BODY>
</HTML>



I have copied both files into c:\inetpub\wwwroot\count  and there is a virtual directory called count which is pointing to c:\inetpub\wwwroot\count

so to access this I am entering http:\\localhost\count\vistors.asp

The result is :-  There are active visitors.  (As you can see there is no figure)  I have tried to refresh a few times and still the same..

HELP!!!





-------------
If you dont want my peaches, dont shake my tree


Posted By: Mart
Date Posted: 03 November 2003 at 1:22pm

Global.asa goes in your main directory not in any subfolders.

Mart.



Posted By: Mart
Date Posted: 03 November 2003 at 1:22pm

But you will be  able to access the applications from subdirectorys...



Posted By: Tegwin
Date Posted: 05 November 2003 at 3:19am
Excellent thanks. I have copied the global.asa to the webroot and all is working ok now. Thanks for your help Mart




-------------
If you dont want my peaches, dont shake my tree



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net