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 can I get the local machine's IP address in a Test.aspx form ?[modified]

How can I get the local machine's IP address in a Test.aspx form ?[modified]

Scheduled Pinned Locked Moved ASP.NET
question
4 Posts 4 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.
  • R Offline
    R Offline
    Rahad Rahman
    wrote on last edited by
    #1

    How can I get the local machine's IP address in a Test.aspx form ?

    modified on Wednesday, September 16, 2009 11:43 PM

    C S R 3 Replies Last reply
    0
    • R Rahad Rahman

      How can I get the local machine's IP address in a Test.aspx form ?

      modified on Wednesday, September 16, 2009 11:43 PM

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

      Rahad Rahman wrote:

      a Windows.Forms app?

      This is the ASP.NET forum.

      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.

      1 Reply Last reply
      0
      • R Rahad Rahman

        How can I get the local machine's IP address in a Test.aspx form ?

        modified on Wednesday, September 16, 2009 11:43 PM

        S Offline
        S Offline
        sashidhar
        wrote on last edited by
        #3

        Try This

        string ip;

        ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR");
        if(ip==string.Empty)
        {
        ip=Request.ServerVariables("REMOTE_ADDR");
        }

        If It Helps Click It as Answer

        1 Reply Last reply
        0
        • R Rahad Rahman

          How can I get the local machine's IP address in a Test.aspx form ?

          modified on Wednesday, September 16, 2009 11:43 PM

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

          This works fine..

          string hostName = System.Net.Dns.GetHostName();
          string clientIP = System.Net.Dns.GetHostAddresses(hostName).GetValue(0).ToString();
          Response.Write(clientIP);

          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