ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Losing my visitors --> Part 2

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
344 active users
1731 visitors today
2587 pages today
how is this done?
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

CoverYourASP
Copyright © 1999-2008 James Shaw.
All rights reserved.

ASP.NET Blog
ASPRSS
ShawThing

Now open source with SourceForge!

But you'll be pleasantly surprised to see that they always match - no matter how quickly you try to leave the page. This is because the script keeps running, even if the user has left the page.

This is an important point. If the user visits a page that requests 50,000 records from your database, then closes his browser, shuts down his computer and goes home, your server is still patiently sending carefully formatted HTML to his IP address! This is again getting off the point of this article, but to detect if a user is still listening when performing a lot of work on a page you may want to sprinkle some of these around:

// is user still waiting for this page?
if ( !Response.IsClientConnected ( ) )
{
   // no, so lets quit
   Response.Clear ( );    // clear buffer
   Response.End ( );    // quit processing
}

The code above only helps if you're doing a lot of processing - chances are that even with this code you'll still get the same number of headers and footers viewed! Aaaaaah! This time it's because you're probably using Response.Buffer = true; and the script executes very quickly. The time is really spent sending the HTML down the 28.8k modem the user is using.

So, using the above method won't work, but a very similar one will. Move the code that increments the footer counter into a new file, then call it client-side as an image, the same way my counter works. This means that the header gets incremented when the script starts processing, and the footer is incremented when the user has downloaded all the HTML, which is actually what you care about.

Part 3: The CountLosses.asp file...

Featured sponsor
My favorite resources

Selling products online - read how James does it now



Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!

CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?