One technique that I wanted to learn about was logging. I have used Google Analytics and it is amazing what information is available but I am also a server administrator so I am used to running scripts when tasks occur. I did some research to figure out a way to create a log file in ASP.NET.
The best resource I found was a forum posted titled How to log a client IP address. It was a straightforward solution to log an IP address, the date and time. I created a test ASPX file and the related text file.
My first issue was with the Server.MapPath method. The path was a generic one of (“/MySite/LogFiles/IpLog.txt”). I wasn’t sure how to edit this to work on my actual website. I did some more research found another article titled Server.MapPath() in ASP.NET. This article gave some sample code on how to dynamically test the different mapping directly on the server. So, I created another test ASPX file and figured I needed to change the path to (“~/LogFiles/IpLog.txt”) to get it to work.
The last issue was permissions. I needed to change the permissions to my new LogFiles folder to have write permissions.