Get users IP address

Rate It (5)

Last post 12-08-2009 5:49 AM by liza20005. 56 replies.

Sort Posts:

  • Re: Get users IP address

    05-24-2009, 12:58 AM
    • Member
      2 point Member
    • Promas
    • Member since 05-24-2009, 4:54 AM
    • Posts 1

    Please try with this

    <%

    string strHostName = System.Net.Dns.GetHostName();
    string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(1).ToString();
    Response.Write(clientIPAddress);

    %>

    Thanks

  • Re: Get users IP address

    07-02-2009, 2:31 AM
    • Member
      52 point Member
    • jaishankar2704
    • Member since 05-17-2007, 7:20 AM
    • Hyderabad
    • Posts 237

    You can use : 

    HttpContext.Current.Request.ServerVariables.Get("REMOTE_ADDR");

    Thanks & Regards
    Jai
  • Re: Get users IP address

    07-23-2009, 6:36 PM
    • Member
      28 point Member
    • sheryarnizar
    • Member since 01-03-2008, 9:57 AM
    • Karachi
    • Posts 14

    Following are the ways. to get IP Address

    1. HttpContext.Current.Request.ServerVariables.Get("REMOTE_ADDR");

    2. Context.Request.ServerVariables ["REMOTE_ADDR"].ToString();

    3. Request.UserHostAddress.ToString();

    4. string myHost = System.Net.Dns.GetHostName();


    Regards

    Sheryar Nizar

    --
    Sheryar Nizar
    http://www.sheryar.net
  • Re: Get users IP address

    10-28-2009, 5:20 AM
    • Member
      2 point Member
    • viveksisodia
    • Member since 10-28-2009, 9:12 AM
    • Posts 1

    HttpContext.Current.Request.UserHostAddress.ToString()

    Request.ServerVariables["REMOTE_ADDR"].ToString()

    both are the same.

  • Re: Get users IP address

    11-02-2009, 9:15 AM
    • All-Star
      62,769 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 1:34 PM
    • England
    • Posts 12,247
    • TrustedFriends-MVPs

    If you are trying to get your own external IP Address, please see http://externalip.codeplex.com/

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Get users IP address

    11-05-2009, 5:32 AM
    • Participant
      866 point Participant
    • Babunareshnarra
    • Member since 07-12-2009, 7:10 AM
    • Hyderabad
    • Posts 179

    Try this

              Request.ServerVariables["REMOTE_ADDR"]

    Regards

    Babu Naresh Narra

    Remember to click “Mark as Answer” on the post If you get answer from my post(s) !
  • Re: Get users IP address

    11-05-2009, 5:44 AM
    • Member
      8 point Member
    • Manwatkar
    • Member since 10-27-2009, 5:49 AM
    • Nagpur,pune
    • Posts 4

    dear sir.

    i have applied your code in my project

    string strHostName = System.Net.Dns.GetHostName();
                    string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

    but it working correctly on localhost but when i am trying on the server it is giving as address like this 10.49.23.4 which address is this please reply me what is the problem....my email address is pank_manwatkar2007@yahoo.com thanks in advance....


  • Re: Get users IP address

    11-05-2009, 1:55 PM
    • Member
      6 point Member
    • villandro
    • Member since 01-22-2009, 2:55 PM
    • Posts 3

    Try this:

    string clientIP = Request.UserHostAddress.ToString();

     

  • Re: Get users IP address

    11-06-2009, 2:01 AM
    • Member
      8 point Member
    • Manwatkar
    • Member since 10-27-2009, 5:49 AM
    • Nagpur,pune
    • Posts 4

    dear sir,

    i have tried this als but it is giving me ip 127.0.0.1 can u tell me

    Dim strHostName As String = System.Net.Dns.GetHostName()
            Dim clientIPAddress As String = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString()


    when i applying this code on local host it is working fine but when i was using it on server it is giving this ip address 10.49.39.51 which ip address is this bcoz i was getting same ip address whn i using it from anywhere...

    is there any other way to get the ip address which really work...please help me out....thnks in advance...


    Filed under:
  • Re: Get users IP address

    11-10-2009, 1:24 PM
    • Member
      2 point Member
    • alikhanweb
    • Member since 11-10-2009, 6:24 PM
    • Posts 1

    This worked for me.

    Thank you so much.  

  • Re: Get users IP address

    11-15-2009, 2:42 PM
    • Member
      2 point Member
    • jamalqudah
    • Member since 11-15-2009, 7:37 PM
    • Dubai
    • Posts 1

    simply if you run the code on a class or the global you wont be able to get the remote IP address

    just run this code on any code behind page and you'll get the remote user IP

     Request.UserHostName

    you can try my URL http://www.jamalq.com/testing.aspx

    if you need the IP on the class just pass it through string

     hope this help

    Developments No limits!
  • Re: Get users IP address

    12-08-2009, 5:49 AM
    • Member
      22 point Member
    • liza20005
    • Member since 12-07-2009, 9:19 AM
    • Posts 11

    hmmm nice very niceeeee

    Tamil mobile songs are always a pleasure.
Page 4 of 4 (57 items) < Previous 1 2 3 4