Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Visitor IP address

Visitor IP address

Scheduled Pinned Locked Moved ASP.NET
tutorial
6 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pkp001
    wrote on last edited by
    #1

    Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj

    J P J C 4 Replies Last reply
    0
    • P pkp001

      Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      You don't. Thats exactly the purpose of proxy's.

      1 Reply Last reply
      0
      • P pkp001

        Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj

        P Offline
        P Offline
        pd69
        wrote on last edited by
        #3

        The below given code gives you the IP address of the User Accessing the site: HttpContext.Current.Request.UserHostAddress; OR HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; To get the IP address of the machine and not the proxy use the following code: HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; I hope this was useful !!! :cool:

        A 1 Reply Last reply
        0
        • P pd69

          The below given code gives you the IP address of the User Accessing the site: HttpContext.Current.Request.UserHostAddress; OR HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; To get the IP address of the machine and not the proxy use the following code: HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; I hope this was useful !!! :cool:

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          I think he already mentioned these are not working for him. :(

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Windows7 API Code Pack
          Simplify Code Using NDepend
          Basics of Bing Search API using .NET

          1 Reply Last reply
          0
          • P pkp001

            Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj

            J Offline
            J Offline
            Jeneesh K Velayudhan
            wrote on last edited by
            #5

            Hi pkp001, As pd69 said, HttpContext.Current.Request.UserHostAddress; this code will return the IP of the requested machine.

            Thanks & Regards, Jeneesh k. v.

            1 Reply Last reply
            0
            • P pkp001

              Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj

              C Offline
              C Offline
              carlecomm
              wrote on last edited by
              #6

              Get the visitor's actual IP address? Do you mean the visitor is using proxy? Try this function: Private Function getIP() Dim strIPAddr If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then strIPAddr = Request.ServerVariables("REMOTE_ADDR") ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1) ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1) Else strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR") End If getIP = Trim(Mid(strIPAddr, 1, 30)) End Function You can also get the visitor's IP by Request.UserHostAddress.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups