What methods can I use to track the number of active visitors on my asp.net website?

I am seeking a more accurate way to track the number of current visitors to my asp.net website. While I am familiar with the common technique of creating an application variable and increasing it at session start, this method tends to inflate the numbers by counting requests from web crawlers, robots, and other spammer servers.

What I truly desire is a system that can differentiate between active human users who have opened up a browser (whether on mobile or desktop) to view my site, even if they are simultaneously browsing other websites in different tabs or windows. Essentially, I want a mechanism like an ajax hidden request generator that sends a signal to the server each time a visitor's browser has my site open.

Thank you for your assistance.

Answer №1

To determine if a request is from a search engine crawler, you can check the user-agent of the request using Request.Browser.Crawler. This will return true if the browser is identified as a crawler.

In addition to this method, you could also incorporate a javascript call to update the visitor count on a page. By combining these techniques, you can ensure that visitor counts are only updated for real users. It is important to verify that the request is not from a crawler when increasing or decreasing the user count. For example:

//increase the user count
if (Request.Browser.Crawler == false)
{
    Application["user_count"] = +1;
}

//decrease the user count
if (Request.Browser.Crawler == false)
{
    Application["user_count"] = -1;
}

Another approach is to utilize the Session_End and Session_Start events in the global.asax file of the application to handle these actions.

Answer №2

Storing data using the Application is a viable option, especially in the initial phases of your website or web application. However, it's important to address potential issues related to accessing multiple instances of the application state when the site is being loaded.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When trying to make a jQuery call using ajax, there is no response being received

I'm facing a slight issue with a gift list that is generated from SQL. My objective is to display each row as a form with a textbox and a button. When the button is clicked, I want to send the textbox value and an ID number (hidden field value) to a f ...

Error: Certain Prisma model mappings are not being generated

In my schema.prisma file, I have noticed that some models are not generating their @@map for use in the client. model ContentFilter { id Int @id @default(autoincrement()) blurriness Float? @default(0.3) adult ...

Adding a user mention to a message in a reactjs application - a step-by-step guide

I am a beginner in JavaScript programming and I want to incorporate user mentions into messages using React without relying on any plugins. What is my goal? I have an input field for messages. When a user types the @ symbol, I want a dropdown menu to app ...

retrieving dynamic data from an HTML form to JavaScript

Currently, I am dynamically adding elements using JavaScript. The count is defined and increases by one. <span style="margin-left:10px;">File Type : <select name="select_type_'+count+'" > <option value="select">Select</optio ...

What is the appropriate way to incorporate a dash into an object key when working with JavaScript?

Every time I attempt to utilize a code snippet like the one below: jQuery.post("http://mywebsite.com/", { array-key: "hello" }); An error message pops up saying: Uncaught SyntaxError: Unexpected token - I have experimented with adding quotation m ...

Stopping the execution of code in ASP.NET

I am facing an issue on my ASP.NET website where a user can retrieve large data from a database by clicking a button. However, sometimes the user needs to cancel the job, which can take a very long time, and their session ends up hanging while the job is i ...

What is the best way to retrieve an axios response in Vue.js using a v-on:click event with asynchronous functions and try/catch blocks?

Can someone assist me? I am attempting to retrieve an object response from an API using axios in an async function with try and catch blocks. Currently, when I make the request, I receive: Promise { pending }. How can I access my object? Here is a snippet ...

Leveraging multiple update panels within asp.net

Greetings, I have a question that has arisen during my work. I am utilizing four distinct update panels, each triggered by the same timer. Here are my queries: 1) Are four separate HTTP requests sent to the server when the update panels are triggered? 2) ...

Using Vue components in a TypeScript file

I recently started using Vue.js with TypeScript and stumbled upon this GitHub repository. While working on it, I encountered an issue where I received an error while trying to import a Vue Single Component File from TypeScript. My development environment ...

How to prevent the default Highcharts pie from appearing on an Angular page during loading

After successfully displaying my HighCharts half-doughnut with hard-coded data, I ran into a problem when trying to fetch data from the database. The slight delay in loading the data caused an issue where a "Chart title" and a white box would appear on the ...

"Selecting an object in Three.js after it has been deleted

Implementing object picking in code is a popular technique: function Picking(event) { var raycaster = new THREE.Raycaster(); event.preventDefault(); mouse.x = (event.clientX / renderer.domElement.clientWidth) * 2 - 1; mouse.y = -(event.clientY / renderer. ...

I am encountering difficulties with importing Node modules into my Vue.js project

Having some trouble importing a node module via NPM in a Vue.js single file component. No matter which module I try to install, it always throws an error saying These dependencies were not found. I'm following the installation instructions correctly ( ...

Tips for preserving input field data in an AngularJS scope variable

I am having trouble storing textbox values in my 'Values' variable. When I enter values in the textboxes, it seems to be getting the hard-coded values instead. Can someone please help me with this AngularJS issue as I am new to it? Here is the co ...

Iterate through the values of an object and verify their presence in another object

I am working on a function where I need to check if any of the role names, passed in as a string with or without pipe separation, exist within an existing JavaScript array. While .includes works well for single names, it doesn't work perfectly when d ...

Vue is struggling to load the component files

Lately, I've been encountering an error during webpack build that is causing some issues. ERROR There were 3 errors encountered while compiling The following relative modules could not be found: * ./components/component1.vue in ./resources/assets/ ...

Issue with exporting Crystal Reports causing error message "Parameter Values Missing"

I am encountering an issue while attempting to export a report using the crystalreportviewer. Each time the code runs to export the crystal report, I receive an error message indicating "Missing Parameter Values". Despite thorough research, I have not been ...

Is there a more efficient method for managing Express rendering based on whether the request is an AJAX post or an HTML form submission?

Currently, I am working on an HTML form and incorporating jQuery's AJAX post feature to retrieve information based on the success or failure of a database insertion. Within my code, I have set the ajax post variable to true when utilizing AJAX postin ...

The Angular controller encountered an unexpected token

I have organized all my Angular controllers in one controller file. However, I encountered an issue when trying to print out a specific part of my object array at the end of a controller. Everything worked fine until I added a new controller after the cur ...

Having trouble with the Bootstrap navbar on your iPad?

I have a navigation bar on a website I am developing. It is functioning correctly on Windows browsers (Chrome, Firefox, IE), Mac OS browsers (Chrome, Firefox, Safari), and Android browsers (Chrome, Firefox). However, when I try to click on the File menu fr ...

React Native application fails to return any values from an asynchronous operation in App function

Completely new to React Native, this is my first attempt at coding. I'm struggling with returning jsx from my App() function due to an asynchronous operation within it. Here's the code that I believe clearly demonstrates my issue: import React fr ...