Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 9th, 2003, 07:49 PM
Authorized User
Join Date: Jun 2003
Location: Sylmar, CA, USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gumgak
Default hit counter

I am using ASP.NET with C#.
i once saw the code that generates hit count using server control / session. it was really simple.

can anyone help me with this?
Reply With Quote
  #2 (permalink)  
Old July 10th, 2003, 01:07 PM
Authorized User
Join Date: Jun 2003
Location: Sylmar, CA, USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to gumgak

Following code works well for the session. however i need to find out how to track the number of visitors using web.conf. can anyone help?

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.ComponentModel" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.IO" %>

<script language="C#" runat="server" >
    void Page_Load(object sender, System.EventArgs e)
        int count = 0;
        if (!(Page.IsPostBack)){
            count = SessionHitCounter();
        SessionCount.Text = Convert.ToString(count);

    public int SessionHitCounter()
       if (Session["HitCounter"] == null) {
          Session["HitCounter"] = 1;
       else {
          Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
       return ((int) Session["HitCounter"]);

     void EnterBtn_Click(Object Src, EventArgs E)
          // Populate the text box with the results from the call to the XML Web service method.
          int i = SessionHitCounter();
          SessionCount.Text = Convert.ToString(i);


<TITLE>counter test</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <form runat="server" id="Form1">
        <asp:button text="Bump Up Counter" Onclick="EnterBtn_Click" runat=server ID="Button1" NAME="Button1"/>
        hit counter:
        <ASP:LABEL ID="SessionCount" runat="server"></ASP:LABEL>
Reply With Quote
  #3 (permalink)  
Old November 2nd, 2003, 12:44 AM
Authorized User
Join Date: Nov 2003
Location: Norco, CA, USA.
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts

Have you found an answer?
I have the same question and have entered the code in that question which is now one the Active Topics. Please look at it. I'm using a Session State object on the Global.aspx.cs page.
Where did you declare count, and SessionCount, and HitCount?

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
A Hit Counter, PLEASE HELP !!!!! ARD_40 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 April 23rd, 2006 06:25 AM
Hit Counter Help! NeilS21 Classic ASP Databases 4 April 29th, 2005 06:59 AM
Hit Counter mateenmohd HTML Code Clinic 7 September 28th, 2003 07:22 AM

All times are GMT -4. The time now is 05:03 AM.

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