Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1031571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T13:57:02+00:00 2026-05-16T13:57:02+00:00

Hello I am creating a basic counter that adds +1 everytime someone accesses the

  • 0

Hello I am creating a basic counter that adds +1 everytime someone accesses the website. The problem is it adds 1 everytime someone goes to another page on the site, not when the person goes to the site for the first time, making the data very inaccurate (ex. One user that accesses the site may go to 8 different pages, therefore adding 8 to the counter, insead of 1). Is there a way to detect when a user is accessing the site on the first initial load?

I’m using asp.net 3.5 in C#.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T13:57:02+00:00Added an answer on May 16, 2026 at 1:57 pm

    Try using the Session_Start event in Global.asax.cs

        protected void Session_Start(object sender, EventArgs e)
        {
              //Increment your counter here
    
        }
    

    This will add one to the counter for each user, the first time they hit a page on your site. Then, once the browser session has timed out (by default 20 minutes of inactivity on your site), another increment will occur the next time the hit your site. The timeout period is configurable.

    If you want to do it for the first time they EVER hit your site, then the cookie approach mentioned by some other posters will do this. But remember, you have no way of knowing whether it is the same user, just the same computer – think Internet cafe.

    Edit: Following your comment about anonymous users:
    What are your authorizatioin settings? e.g.

    <!-- Allow access to anonymous (unauthenticated) users. -->
    <authorization>
      //probably shouldn't do this in particular, but you might want to look at your settings
      <allow users="*" /> 
    </authorization>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all I am creating a horizontal menu for a site that needs to
I am currently creating a small HTTP server that returns a static page <p>Hello!</p>
Hello I am creating a Windows application (WPF) that is going to be running
Hello I am creating a CMS and some of the functionality of it that
Hello I'm currently creating a mobile site for a business. And I wanted to
Hello I am creating a windows application that will be installed in 10 computers
Hello I am creating a system with a gun that shoots bullet. The update
Hello dearest community, I run into problem of creating an exact MD5 of a
I'm creating a basic C program that uses the mysql api. I'm on windows,
Hello i am creating a small webpage that give our users an interface to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.