Discussion Locked

Newbie at ASP Code

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want to try this free ASP counter out.
http://www.powerasp.com/content/code-snippets/hit-counter.as p

Looks simple and great but I have spent time and time again trying to figure out how to get this to work on my pages. Can not figure out how to get the code to work on an existing HTML page.

All my pages are made in Frontpage 2003.

I have many pages in the same folder, so I do not know if the code will just work or I need to make several sub directories (codemain, codefamily, codesports, etc) to make each counter.txt keep ther correct number for each page.

I have figured out to add some content before and after the code, but not know how to get the code to work at the beginning or end of an existing HTML.

All I need to know is how to:
1 - Make the code work on an existing page.
2 - Make the code work for another page in the same directory as the above, but not have the counter.txt conflict.

Thank you very much for any help. I know there has got to be some ASP experts around here.

I tried posting to those message boards but no one has been answering.

13 replies

by bschaettle

I didn't have time to look at the powerasp example, but this code works on my intranet.
Just paste it into the HTML where you want the hit counter. Your Webpage must have a ".asp" file extension, as well.

==========================================
<%
Dim objPageCount, iHits
Set objPageCount = Server.CreateObject("MSWC.PageCounter")
objPageCount.PageHit() ' Increment the counter
iHits = objPageCount.Hits() ' save the number of hits in a local var
Set objPageCount = Nothing ' release memory
%><%=iHits%>

by borginva

bschaettle,
I did not think of saving them in ASP instead of HTM or HTML. I tried that and it still did not work. Also used the code you provided. Even if I start a fresh clean page with no code, when I enter in any of this ASP code, that is exactly how I view it. Same results if I put the code into an existing HTM code and saved as .ASP.
Am I missing something to make ASP work on my end? I can view oither sites' ASP pages.
I have been searching but can not find the right site to get me going.
Let me know if you think I ma missing something to make it work on my end.
Again, most of my pages made in Frontpage 2003. Few from fresh text (like Notepad). Running on XP Pro SP2 using IISv5.1.
Thanks for a good lead too.

by borginva

I found a site giving a small demo on using ASP. Not much to the site but it gave some explainaing of ASP and some date and time scripts.
If I just use this simple script on a blank page:
<% =date %>
and saved as test1.asp,
My page will still not show the code. So for some reason, I can not even use something this simple.
Any ideas what I could be missing?
I have found another site talking about an ASP directory but doing a Google on those words together is not giving me the info I am trying to find.

by bschaettle

BorgInva,
It sounds like your server may not be set up to process Active Server Pages. As an experiment, embed this code:
<%=Now%>
in a .asp file, save the file, and view it in a browser.
If you do not see the current date and time displayed on the page, then your web server is not set up to process Active Server Pages.

by borginva

bschaettle,
That is my problem, I used your now script and the <% =date %> one and neither works. I am trying (and posted a seperate topic) on what it is I need to do to make my PC see this correctly. I checked a bunch of the MS pages but they all say the same thing. Just about IIS and nothing about ASP except that IIS uses it.

by bschaettle

RE: "...to make my PC see this correctly..."

BorgInva,
Are you just viewing this .asp page within FrontPage? I'm not sure that will work for ASP. For best results, view it in a separate browser session at whatever http:// address it's been published to.

If you have FrontPage installed, I think there should be a web service running on your PC. Try typing
http://localhost
into your browser address bar and see what comes up. The webpages at this site should correspond to a folder on your hard-drive named
C:\inetpub\wwwroot\
The fact that you're seeing the ASP code displayed in your browser tells me that the web server you're using isn't recognizing the <%%>
brackets as containing server-side code.

Also, if you're viewing the file using the "file" protocol, e.g.,
file:///c:\foldername\foldername\mypage.asp
I don't think your ASP code will get interpreted either. ASP pages have to be viewed via the http protocol through a web server that can interpret the server-side code. Without this the server-side code will just get sent to the browser which will just display it as text, which is what you're seeing.

Good luck!

by borginva

B,

"Are you just viewing this .asp page within FrontPage? I'm not sure that will work for ASP. For best results, view it in a separate browser session at whatever http:// address it's been published to."

Firefox and IE. I never use FrontPage to view, only modify. I use FF and IE to view from my local PC and outside my home network. Externally and internally (http://192.168.0.3:port), ASP pages will not show.

"If you have FrontPage installed, I think there should be a web service running on your PC. Try typing
http://localhost
into your browser address bar and see what comes up. The webpages at this site should correspond to a folder on your hard-drive named
C:\inetpub\wwwroot\"

I get an invalid page (page not found). I changed IIS to see the home directory in another location but I never touched the c:\inetpub files. My website works internally and externally using the home directory I told IIS to look at. Been running fine for over 2 years.

Even externally on a different PC using HTTP://websitename, or even internally using http://192.168.0.3, only the ASP code shows. All HTMLS work.

Let me see what is going on with that localhost command and see if that has anything to do with it.

by patof

Have you flush your buffer, may be your browser is not refreshing... happened to me.. you may add some standard html code to indicate a new file version is available...

Are you sure Frontpage is not translating the <% and %> to show them on the page? What do you see exactly on your browser when you access the page? blank screen or what?

by borginva

patof,

All browers cleared of anything.

As for the code, what I put in is what I see in any browser. So, if I take a blank page, add in:
<% =date %>
And view it in IE or FF, my PC or a remote, I see the same exact thing:
<% =date %>

Same results with any code, including what you seen posted on this, er, post:

<%
Dim objPageCount, iHits
Set objPageCount = Server.CreateObject("MSWC.PageCounter")
objPageCount.PageHit() ' Increment the counter
iHits = objPageCount.Hits() ' save the number of hits in a local var
Set objPageCount = Nothing ' release memory
%><%=iHits%>

or

<%=Now%>

or

<%=time%>

Something with IIS v5.1 or Windows (Sp Pro SP2) will not let me see ASP code based off my own PC. IIS has been uninstalled and reinstalled several times with ALL options.

This discussion is closed to new replies.