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. Collect Visitor's IP

Collect Visitor's IP

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
7 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.
  • S Offline
    S Offline
    sjmclean
    wrote on last edited by
    #1

    Anyone got a link to a good tutorial which shows how to create a read-only text-box in a Web Application which automatically collects a visitor's IP Address? Thanks

    C A R 3 Replies Last reply
    0
    • S sjmclean

      Anyone got a link to a good tutorial which shows how to create a read-only text-box in a Web Application which automatically collects a visitor's IP Address? Thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      It's in the Request object ( the IP address ). Use a label, that's read only.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      D 1 Reply Last reply
      0
      • S sjmclean

        Anyone got a link to a good tutorial which shows how to create a read-only text-box in a Web Application which automatically collects a visitor's IP Address? Thanks

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

        Here you go...

        txtbox.Text = Request.ServerVariables["REMOTE_HOST"];
        txtbox.Attribures.Add("readonly", "readonly");

        . :)

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        1 Reply Last reply
        0
        • S sjmclean

          Anyone got a link to a good tutorial which shows how to create a read-only text-box in a Web Application which automatically collects a visitor's IP Address? Thanks

          R Offline
          R Offline
          Robert_Pan
          wrote on last edited by
          #4

          public static string GetLocalAddress()
          {
          IPAddress[] addressLocal = Dns.GetHostByName(Dns.GetHostName()).AddressList;
          if (addressLocal.Length > 0)
          {
          return addressLocal[addressLocal.Length - 1].ToString();
          }
          return "127.0.0.1";

          }
          
          M 1 Reply Last reply
          0
          • C Christian Graus

            It's in the Request object ( the IP address ). Use a label, that's read only.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #5

            Why was this reply voted one?

            It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

            M 1 Reply Last reply
            0
            • R Robert_Pan

              public static string GetLocalAddress()
              {
              IPAddress[] addressLocal = Dns.GetHostByName(Dns.GetHostName()).AddressList;
              if (addressLocal.Length > 0)
              {
              return addressLocal[addressLocal.Length - 1].ToString();
              }
              return "127.0.0.1";

              }
              
              M Offline
              M Offline
              Manas Bhardwaj
              wrote on last edited by
              #6

              This would always give the server address.

              Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

              1 Reply Last reply
              0
              • D dan sh

                Why was this reply voted one?

                It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

                M Offline
                M Offline
                Manas Bhardwaj
                wrote on last edited by
                #7

                Because, he did not give him the complete code snippet. ;P

                Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

                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