Click here to Skip to main content
16,015,393 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to store IP address of client machine to my database.without user interaction . automatically i want to capture IP address of client machine and get stored it into database how do i accomplish this?. I just want to keep track of IP address by which data has been updated.




Thanks
Posted

You could use Request.ServerVariables["REMOTE_ADDR"] value to have IP address of client and using DB operation you could simply insert it.

Please vote and Accept Answer if it Helped.
 
Share this answer
 
You can get the IP address using server variables.And you can store it, every time when a new session starts or when user login to your application, according to you requirement.
 
Share this answer
 
Hi,

There are two options by which you can do :
string[] computer_name = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' });

txt_ipaddress.Text = strClientIP.ToString() + "[" + computer_name[0].ToString() +"]"; 

after getting IP you can store it in Database.
Thanks ,
Pawan
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900