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. How to find IP address of user machine in ASP.

How to find IP address of user machine in ASP.

Scheduled Pinned Locked Moved ASP.NET
tutorialsysadminquestion
16 Posts 5 Posters 2 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.
  • R rahul net11

    Hi In my application i want to find ip address of the user machine who is accessing my application.I am develop an application for it but it gives me ip address of my server i.e the server on which my application is running but i want to find out ip address of the machine who is accessing my application.How can i do this using ASP. Please guide me to solve this. Thanks.

    Rahul

    U Offline
    U Offline
    Urs Enzler
    wrote on last edited by
    #7

    HttpContext.Current.Request.UserHostAddress

    -^-^-^-^-^- no risk no funk ................... please vote ------>

    R 1 Reply Last reply
    0
    • F Fred_Smith

      OK.. try using: Dim ip as string = Request.UserHostAddress

      R Offline
      R Offline
      rahul net11
      wrote on last edited by
      #8

      HI I tried this it gives me following error. Microsoft VBScript runtime error '800a01b6' Object doesn't support this property or method: 'UserHostAddress'

      Rahul

      F 1 Reply Last reply
      0
      • R rahul net11

        HI I tried this it gives me following error. Microsoft VBScript runtime error '800a01b6' Object doesn't support this property or method: 'UserHostAddress'

        Rahul

        F Offline
        F Offline
        Fred_Smith
        wrote on last edited by
        #9

        Well this is an ASP.NET forum, not VBScript... I suggest you try Googling "client ip address vbscript" and follow up some of the results...

        R 1 Reply Last reply
        0
        • F Fred_Smith

          Well this is an ASP.NET forum, not VBScript... I suggest you try Googling "client ip address vbscript" and follow up some of the results...

          R Offline
          R Offline
          rahul net11
          wrote on last edited by
          #10

          I know this is asp.net forum i have implemented same application using asp.net also when i run the application on local machine it gives me correct ip address and when i am upload this to server and run the page then it also show me server ip address and server name insted my machine name. Ok thanx for u r help.

          Rahul

          F 1 Reply Last reply
          0
          • R rahul net11

            I know this is asp.net forum i have implemented same application using asp.net also when i run the application on local machine it gives me correct ip address and when i am upload this to server and run the page then it also show me server ip address and server name insted my machine name. Ok thanx for u r help.

            Rahul

            F Offline
            F Offline
            Fred_Smith
            wrote on last edited by
            #11

            Ths may help: (you'll ned to convert ot VB) string ip; ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR"); if(ip==string.Empty) { ip=Request.ServerVariables("REMOTE_ADDR"); } REMOTE_ADDR does not always provide the users IP but rather the ISPs' IP address so first test HTTP_X_FORWARDED_FOR as this one is the real user IP.

            R 1 Reply Last reply
            0
            • U Urs Enzler

              HttpContext.Current.Request.UserHostAddress

              -^-^-^-^-^- no risk no funk ................... please vote ------>

              R Offline
              R Offline
              rahul net11
              wrote on last edited by
              #12

              HI i tried this it gives me my server ip address not my machine ip address. again any solution. Thanks.

              Rahul

              U 1 Reply Last reply
              0
              • F Fred_Smith

                Ths may help: (you'll ned to convert ot VB) string ip; ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR"); if(ip==string.Empty) { ip=Request.ServerVariables("REMOTE_ADDR"); } REMOTE_ADDR does not always provide the users IP but rather the ISPs' IP address so first test HTTP_X_FORWARDED_FOR as this one is the real user IP.

                R Offline
                R Offline
                rahul net11
                wrote on last edited by
                #13

                Thanx I tried that but the result is same as before.Is there any server setting required for that purpose. Thanks.

                Rahul

                1 Reply Last reply
                0
                • R rahul net11

                  HI i tried this it gives me my server ip address not my machine ip address. again any solution. Thanks.

                  Rahul

                  U Offline
                  U Offline
                  Urs Enzler
                  wrote on last edited by
                  #14

                  In our web applications this works just fine. Seams that the problem is something different.

                  -^-^-^-^-^- no risk no funk ................... please vote ------>

                  P 1 Reply Last reply
                  0
                  • U Urs Enzler

                    In our web applications this works just fine. Seams that the problem is something different.

                    -^-^-^-^-^- no risk no funk ................... please vote ------>

                    P Offline
                    P Offline
                    pkp001
                    wrote on last edited by
                    #15

                    Could you please elaborate Where you have hosted your web application. Its localhost or outside ur network??

                    U 1 Reply Last reply
                    0
                    • P pkp001

                      Could you please elaborate Where you have hosted your web application. Its localhost or outside ur network??

                      U Offline
                      U Offline
                      Urs Enzler
                      wrote on last edited by
                      #16

                      The web application was hosted on a dedicated server that was accessible locally, or from intranet or over internet. the IP could always be requested in the way I explained some post earlier. However, this was a long time ago, on a different .NET version that today's. Hope that helps...

                      -^-^-^-^-^-^-^- planetgeek.ch

                      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