how to get user's HostName, IP, and MAC Address ? and how to store in database?
how to get user's HostName, IP, and MAC Address ? and store in database?when user's visit site automatically store in data base
help me plz
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anil KumarRank #2,740 · 511 reputationPosted Feb 22, 2015, 6:17 AM EST
Sample code :-
IPHostEntry objEntry = Dns.GetHostEntry(Dns.GetHostName());
IPAddress[] arrAddress = objEntry .AddressList;
string host = objEntry .HostName.ToString();
string ip = arrAddress [2].ToString();
Don't forget to include the namespace.
Play with the object, i hope you'll find something for getting physical address as well
Khargesh RajputRank #616 · 3.9K reputationPosted Feb 22, 2015, 5:25 PM EST
public string IpAddress()
{
string strIpAddress;
strIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIpAddress == null)
{
strIpAddress = Request.ServerVariables["REMOTE_ADDR"];
}
return strIpAddress;
}
Anil KumarRank #2,740 · 511 reputationPosted Feb 23, 2015, 7:50 PM EST