Wednesday, March 2, 2016

How to get the Curently Logged User IP Address

NameSpace:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;

Return is IP Address
public static string getIPAddress()
    {
        IPHostEntry host;
        string localIPaddr = "?";
        host = Dns.GetHostEntry(Dns.GetHostName());
        foreach (IPAddress addr in host.AddressList)
        {
            if (addr.AddressFamily.ToString() == "InterNetwork")
            {
                localIPaddr = addr.ToString();
            }
        }
        return localIPaddr;
    }

No comments:

Post a Comment