ImDaFrEaK
Well-known member
I would like to Log each time a user enters my site to a text file and I would also like to put a counter on my site to show how many times it has been visited.
I know this is probably simple but I have had a problem doing it. For example. I put the following code into my Page_Load event and it only worked for me during testing. Gave others an error.
'please ignore if the parameters in the FileStream Object are out of place or type wrong I am doing this at work and can't remember the exact syntax but I know it's correct at home.
That code only works for me but not other users.
I know this is probably simple but I have had a problem doing it. For example. I put the following code into my Page_Load event and it only worked for me during testing. Gave others an error.
'please ignore if the parameters in the FileStream Object are out of place or type wrong I am doing this at work and can't remember the exact syntax but I know it's correct at home.
VB.NET:
Dim FS as new FileStream(Server.MapPath("Bin/Log.txt"), File.Append, Access.Write, Share.none)
Dim SW as new StreamWriter(FS)
SW.Writeline(User.Identity.Name & " / " & Date.Now.toString)
SW.Close()
SW.Flush()
That code only works for me but not other users.