Professional Web Applications Themes

Tracking IP - ASP.NET Web Services

Ok, I have website hosting on a server. Is there a way for me to write a program that will track what IP addresses are hitting me site and write them to a textfile Thanks seth...

  1. #1

    Default Tracking IP

    Ok, I have website hosting on a server. Is there a way for me to write a program that will track what IP addresses are hitting me site and write them to a textfile

    Thanks seth
    Seth Guest

  2. #2

    Default Re: Tracking IP

    Sure..here is some quick and dirty code that will do it on an ASP.NET page:

    string IPAddress = Request.ServerVariables["REMOTE_ADDR"]; //get requesting IP using ServerVariables Collection
    string MyFilePath = "C:\webaccess.txt"; //this is for convenience for me, you probably will place it somewhere else

    bool FileExists = File.Exists(MyFilePath);

    //If file Exists is false it will create a new file, if its true it will just append

    StreamWriter sw = new StreamWriter(MyFilePath,FileExists);
    sw.WriteLine (IPAddress);
    sw.Close();


    --
    -------------------------------------------------------
    [url]http://www.qnal.net/inkabletype[/url]

    "Seth" <anonymousdiscussions.microsoft.com> wrote in message news:91BD13D0-46CF-491F-B3BB-7FEA2ACFB462microsoft.com...
    > Ok, I have website hosting on a server. Is there a way for me to write a program that will track what IP addresses are hitting me site and write them to a textfile.
    >
    > Thanks seth
    Kunal Guest

  3. #3

    Default Re: Tracking IP

    Great, thank you. Hey is there a way to get this to work with just html code. Forgive me if that is a stupid questions. But I'm new to web programming.
    Seth N Guest

  4. #4

    Default Re: Tracking IP

    This has to be done on an ASP/APSX page and HTML pages cannot handle any
    server code. Just change the extention of your page to .ASP on add the
    following code

    Your IP address is <%= Request.ServerVariables("REMOTE_ADDR") %>

    If you want to store this to a file then you will need more code.

    P.

    "Seth N" <anonymousdiscussions.microsoft.com> wrote in message
    news:CB9C9207-C3BC-452F-887E-15F304A8C733microsoft.com...
    > Great, thank you. Hey is there a way to get this to work with just html
    code. Forgive me if that is a stupid questions. But I'm new to web
    programming.


    Paul Guest

Similar Threads

  1. Ad Tracking
    By coldpopper in forum Macromedia Flash Ad Development
    Replies: 2
    Last Post: February 13th, 02:57 AM
  2. InDesign tracking vs. Quark tracking?
    By Mike Witherell in forum Adobe Indesign Macintosh
    Replies: 0
    Last Post: July 15th, 10:23 PM
  3. Tracking
    By Broose in forum Macromedia Director Basics
    Replies: 1
    Last Post: January 8th, 03:58 PM
  4. tracking a pid
    By mike in forum Sun Solaris
    Replies: 2
    Last Post: July 27th, 08:33 PM
  5. Tracking changes for web app
    By Adrian Walters in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: July 9th, 08:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139