简体   繁体   English

从客户端获取唯一标识符ASP.Net c#

[英]Get Unique identifier from client ASP.Net c#

Can i get from a client who visits my site some unique key like MAC Address ? 我可以从访问我网站的客户端获得一些像MAC地址这样的独特密钥吗? i'm trying to get this id to store in the db so client can't access it anymore if it already visits the page. 我正在尝试将此ID存储在数据库中,因此如果客户端已经访问该页面,则客户端无法再访问它。

You can't get the MAC Address of your client 您无法获取客户端的MAC地址

to get the IP address use 获取IP地址使用

 string ipaddress; ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ipaddress == "" || ipaddress == null) ipaddress = Request.ServerVariables["REMOTE_ADDR"]; 

http://www.aspsnippets.com/Articles/How-to-get-IP-Address-of-Visitors-Machine-in-ASP.Net.aspx http://www.aspsnippets.com/Articles/How-to-get-IP-Address-of-Visitors-Machine-in-ASP.Net.aspx

To get the user's IP address, you can use what others have suggested. 要获取用户的IP地址,您可以使用其他人的建议。 However, you cannot obtain a user's MAC address unless they are directly connected to your router. 但是,除非直接连接到路由器,否则无法获取用户的MAC地址。

If you want to uniquely identify your user, you should try to identify them by a combination of IP, OS and some other specific data. 如果要唯一标识用户,则应尝试通过IP,OS和其他一些特定数据的组合来识别它们。 However, this will still not be entirely reliable. 但是,这仍然不完全可靠。

If you allow registration on your website, then you could identify users by their e-mail addresses. 如果您允许在您的网站上注册,那么您可以通过其电子邮件地址识别用户。

There is a question on StackOverflow that seems to be about the same thing: How do I uniquely identify computers visiting my web site? StackOverflow上有一个问题似乎是一样的: 我如何唯一地识别访问我网站的计算机? . An answer there suggests the usage of cookies. 那里的答案建议使用cookies。 You might want to check out the following article: Beginner's Guide to ASP.NET Cookies . 您可能需要查看以下文章: ASP.NET Cookie初学者指南

每次给出一个随机十六进制数

string newID= Guid.NewGuid().ToString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM