| Author |
Topic Search Topic Options
|
Tegwin
Senior Member
Joined: 03 September 2003
Location: United Kingdom
Status: Offline
Points: 430
|
Post Options
Thanks(0)
Quote Reply
Topic: Asp Question 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
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
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
|
|
|
 |
Tegwin
Senior Member
Joined: 03 September 2003
Location: United Kingdom
Status: Offline
Points: 430
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 03 November 2003 at 2:50am |
<Script.Language="vbscript" runat="server"> try removing the '.' between script and language.
Mart.
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
Tegwin
Senior Member
Joined: 03 September 2003
Location: United Kingdom
Status: Offline
Points: 430
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 03 November 2003 at 11:20am |
|
|
 |
Tegwin
Senior Member
Joined: 03 September 2003
Location: United Kingdom
Status: Offline
Points: 430
|
Post Options
Thanks(0)
Quote Reply
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
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!!!
Edited by Tegwin
|
|
If you dont want my peaches, dont shake my tree
|
 |