ASP.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 300,354 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 1,915 people online right now. Registration is fast and FREE... Join Now!




ASP.NET Hit Counter

 

ASP.NET Hit Counter, In JScript

trickstar34

29 Jun, 2009 - 11:09 PM
Post #1

New D.I.C Head
*

Joined: 5 Jun, 2009
Posts: 13


My Contributions
OK, I am trying to make a hit counter for my web page but I can't, I keep getting a compilation error. Here is my code that is the problem, but the thing is I don't know why it's wrong.

CODE
<script language="JScript" runat="server">
var counterDoc : XmlDocument = Server.MapPath("design/server/hits/home.xml");
var counterTag : XmlElement = counterDoc.getElementById("hits");
var hits : Int = counterTag.value.ToInteger;
var counter : Int = hits + 1;
counterDoc.file.RemoveChild("counter");
counterDoc.file.CreateElement("counter");
counterDoc.file.counter.SetAttribute("id", "hits");
counterDoc.file.counter.AppendChild(counterDoc.CreateTextNode(counter));
counterDoc.Save("design/server/hits/home.xml");
</script>


And my XML document
CODE
<?xml version = "1.0"?>
<file>
<counter id="hits">0</counter>
</file>


I just can't see whats wrong, can someone help me get to the bottom of this or show me an easier way of doing this?

If you want to see what the error is go to this link.

This post has been edited by trickstar34: 30 Jun, 2009 - 09:30 PM

User is offlineProfile CardPM
+Quote Post


trickstar34

RE: ASP.NET Hit Counter

30 Jun, 2009 - 09:32 PM
Post #2

New D.I.C Head
*

Joined: 5 Jun, 2009
Posts: 13


My Contributions
How come I never get any help. sad.gif
User is offlineProfile CardPM
+Quote Post

smcak_13@yahoo.co.in

RE: ASP.NET Hit Counter

2 Jul, 2009 - 11:13 PM
Post #3

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 1

QUOTE(trickstar34 @ 30 Jun, 2009 - 09:32 PM) *

How come I never get any help. sad.gif

never mind cool.gif ,see i also got stuck in same prob.few days back,we h to handle the porb.u can go for the online help like.. smile.gif

www.freecountercode.com/

www.freestatscounter.com

www.free-counters.co.uk/
etc like this links so good lick to u icon_up.gif
User is offlineProfile CardPM
+Quote Post

johnly

RE: ASP.NET Hit Counter

16 Jul, 2009 - 01:11 PM
Post #4

New D.I.C Head
*

Joined: 28 Nov, 2008
Posts: 3


My Contributions
You can enable AWSTATS in your site which keeps track of all hit counters.

It provides various reports to view the statistics.

You can enable this if it is available in your hosting package.
User is offlineProfile CardPM
+Quote Post

eclipsed4utoo

RE: ASP.NET Hit Counter

17 Jul, 2009 - 03:39 AM
Post #5

Not Your Ordinary Programmer
Group Icon

Joined: 21 Mar, 2008
Posts: 1,808



Thanked: 201 times
Dream Kudos: 500
Expert In: .NET

My Contributions
why don't you use a text file or XML file? you could read from the file during the Session_Start event and increment the counter by one.
User is offlineProfile CardPM
+Quote Post

sknake

RE: ASP.NET Hit Counter

17 Jul, 2009 - 04:06 AM
Post #6

New D.I.C Head
*

Joined: 15 Jul, 2009
Posts: 32



Thanked: 2 times
My Contributions
Yet another tool is SmarterStats for log analysis -- but if you are doing a hit counter I suspect you want to show that on the page? And do you want a site-wide hit counter for unique visitors or page hit counter for each time the page is hit? This may also report duplicate hits
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 07:13PM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month