如何存储客户端计算机的IP地址. [英] How to store IP address of client Machine.

查看:110
本文介绍了如何存储客户端计算机的IP地址.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将客户端计算机的IP地址存储到我的数据库中,而无需用户交互.我想自动捕获客户端计算机的IP地址并将其存储到数据库中,我该如何做到这一点?我只想跟踪更新数据所用的IP地址.




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

推荐答案

您可以使用Request.ServerVariables["REMOTE_ADDR"]值获取客户端的IP地址,而使用DB操作则可以简单地将其插入.

如果有帮助,请 投票 接受答案 .
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.


您可以使用服务器变量获取IP地址.您可以在每次新会话启动时或用户登录到您的应用程序时根据您的要求进行存储.
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.


您好,

您可以通过以下两种方法进行操作:
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() +"]"; 


获取IP后,您可以将其存储在数据库中.
谢谢,
帕旺


after getting IP you can store it in Database.
Thanks ,
Pawan


这篇关于如何存储客户端计算机的IP地址.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆