1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to fetch User's IP Address

Discussion in 'ASP.NET' started by kanetkar.rucha@gmail, Sep 13, 2011.

  1. kanetkar.rucha@gmail

    kanetkar.rucha@gmail New Member

    Joined:
    Sep 13, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I want User's IP Address stored in my access database and it showed in my website when user use my feedback page.
    I want to display message to user ("Your IP Address Is :")
    My site is built in ASP.NET (C#) and database in in Access.
    Please help me and send me the detailed code and where it to put on page.
    :worried::worried::worried: Thanks in advanced
    Please somebody help me
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    Moved to ASP forum.
     
  3. bzforum

    bzforum New Member

    Joined:
    May 20, 2012
    Messages:
    25
    Likes Received:
    7
    Trophy Points:
    0
    Occupation:
    CEO & Founder
    Location:
    Mumbai , India
    Home Page:
    You can use this code
    PHP:
    Response.Write(Request.ServerVariables["remote_addr"]);
    or

    PHP:
    Response.Write(Request.UserHostAddress);
    hope it helped..
     
  4. alia123

    alia123 New Member

    Joined:
    Jan 8, 2016
    Messages:
    65
    Likes Received:
    3
    Trophy Points:
    0
    The following snippet gets the IP address of the machine from which the client visited the website.

    C#
    Code:
    string ipaddress;
    
    ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    
    if (ipaddress == "" || ipaddress == null)
    
        ipaddress = Request.ServerVariables["REMOTE_ADDR"];
    
    VB.Net
    Code:
    Dim ipaddress As String
    
    ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    
    If ipaddress = "" Or ipaddress Is Nothing Then
    
       ipaddress = Request.ServerVariables("REMOTE_ADDR")
    
    End If
     

Share This Page