Tech Off Post

Single Post Permalink

View Thread: How C9 should record IPs -
  • User profile image
    Manip

    I am using a 'transparent cache service' which is a
    proxy forced on me by my ISP (so they can save
    bandwidth). So if you check my IP by the normal
    method you will get the cache server (thus multiple
    users appear to come from the same IP). However if
    you check the HTTP_X_FORWARDED_FOR var in the header
    you will see my true IP and thus can limit things
    such as polls to one IP.
     
     

    string ispIPAddress;

    if(Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null || Request.ServerVariables["HTTP_CLIENT_IP"] != null)
               ispIPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    else
               ispIPAddress = Request.ServerVariables["REMOTE_ADDR"];


    Taken from here (I am not an ASP.Net coder).