Page Photography

page photography

If you own or are interested in developing your own website, which will probably come a time where you want to get a general idea of how many times your site site being visited. There are more elaborate ways to do this, of course, some developers refer to reading the server logs, others suggest using a product third and implementation of its code within your own website.

For the rest of you who would rather just have a general idea if your personal website is receiving about 10 visitors per day or 1000, this little snippet will help you on your way. I developed applications for analysis of site preparation provide statistics on what pages are being viewed, how long the visitor stays on that particular page, which browser you are using, which referred them to the website to begin with and what their IP address and the list goes on. For the sake of this article however, we will use the kiss method.

The level of this Code only requires a minimum knowledge of the environment. NET, and of course your website must be hosted on a Windows server environment. NET.

This code can be copied and pasted in the footer area of any. aspx in your website. In general, would you say at the bottom of the homepage, or at least that's a good place to start.

The first thing I want to do is create an empty text file, call it counter.txt and save it to the root directory. The following step is even easier, copy and paste the code below into your. Aspx page and save it. Make sure system.IO of the class on your page something like this

counter public String ()
(

StreamReader re = File.OpenText (Server.MapPath ( "counterlog.txt"));

string input = null;

MyCounter str = "";

while ((input = re.ReadLine ())! = null)

(

myCounter = myCounter + Entry;

)

re.Close ();

int myInt = int.Parse (MyCounter);

Myint Myint = + 1;

TextWriter tw = new StreamWriter (Server.MapPath ( "counterlog.txt"));

(tw.WriteLine Convert.ToString (myInt));

tw.Close ();

re = File.OpenText (Server.MapPath ( "counterlog.txt"));
input = null;
MyCounter = "";

while ((input = re.ReadLine ())! = Null)

(

MyCounter = MyCounter + entry;

)
re.Close ();

MyCounter return;

)

'Copy this code to the bottom of the page. aspx.

A brief description of what is happening in this code is as follows:

a. create a method called the fight against

b. Call of the StreamReader class library system.IO and read your text file

c. Store the value of the text file into a variable

d. Close the StreamReader

e. StreamWriter Open

f. Add 1 to the variable containing the value of the text file

g. Enter the new value is incremented by 1 for the text file

h. Close the StreamWriter

This last line


is the line that calls the method when someone visits your homepage, for example. You can put all the code at the bottom of the page, or if you are a little more experience with C # that could put in a "code-behind" file or "inclusion" of class methods to keep the code a bit cleaner.

Nothing fancy, but gives me an idea of how active the site recently.
I hope this helps you in the same way that helped me.

Happy Coding!

Ben Cortese is a developer and business analyst for the financial industry and enjoys developing personal websites. View some of them at http://www.InetSite.net [http://76.12.102.39] Copyright 2007. Article can be reprinted as long as author credits are given and content remains unchanged and intact.

Page 3 girl Rosie Jones photo shoot for the DAB Digital Radio launch of BFBS Radio in the UK



Tags: , , , , , , ,

Leave a Reply