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. How to find client IP?

How to find client IP?

Scheduled Pinned Locked Moved Web Development
helptutorialquestion
3 Posts 2 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.
  • A Offline
    A Offline
    A k ch
    wrote on last edited by
    #1

    Hi Frd's Can anybody tell me how to find a client system IP address which is in a LAN and connected to internet. Here i want to find out both public IP and private IP. Please help me.

    Thanks & Regards, Anil Chelasani

    H 1 Reply Last reply
    0
    • A A k ch

      Hi Frd's Can anybody tell me how to find a client system IP address which is in a LAN and connected to internet. Here i want to find out both public IP and private IP. Please help me.

      Thanks & Regards, Anil Chelasani

      H Offline
      H Offline
      Herman T Instance
      wrote on last edited by
      #2
      static public String GetClientIP(Page page)
          {
              //Find the users own IP
              String strIpAddress = String.Empty;
              try
              {
                  strIpAddress = page.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                  if (strIpAddress == null)
                      strIpAddress = page.Request.ServerVariables["REMOTE_ADDR"];
                  if (strIpAddress == null)
                      strIpAddress = page.Request.UserHostAddress;
              }
              catch 
              {
                  strIpAddress = "IP address not Found";
              }
              return strIpAddress;
          }
      

      In Word you can only store 2 bytes. That is why I use Writer.

      A 1 Reply Last reply
      0
      • H Herman T Instance
        static public String GetClientIP(Page page)
            {
                //Find the users own IP
                String strIpAddress = String.Empty;
                try
                {
                    strIpAddress = page.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (strIpAddress == null)
                        strIpAddress = page.Request.ServerVariables["REMOTE_ADDR"];
                    if (strIpAddress == null)
                        strIpAddress = page.Request.UserHostAddress;
                }
                catch 
                {
                    strIpAddress = "IP address not Found";
                }
                return strIpAddress;
            }
        

        In Word you can only store 2 bytes. That is why I use Writer.

        A Offline
        A Offline
        A k ch
        wrote on last edited by
        #3

        Thanks it's a great help for me.

        Thanks & Regards, Anil Chelasani

        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