且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 ASP.NET 应用程序中唯一标识客户端计算机?

更新时间:2022-12-23 19:34:01

我不会讨论你的奇怪场景,只回答你的问题:如何识别机器?

I won't discuss your strange scenario, just answer your question: how to identify a machine?

嗯,目前还没有使用 HTTP 协议的紧密形式的解决方案.所有机器共享相同的 IP,因为它们位于 NAT 之后.您无法获取 MAC 地址.您无法获得硬件标识符.您不能确定所有机器都会向服务器发送不同的标头(即所有不同的浏览器/版本).

Well, there is no close-form solution at current time with HTTP protocol. All machines share the same IP since they are behind NAT. You can't get MAC address. You can't get hardware identifiers. You can't be sure that all machine will send different headers to the server (ie. all different browsers/version).

您可能会依赖 cookie.尝试创建某种形式的机器身份验证,或者更好的机器识别页面,从每台机器上浏览一次,告诉服务器在该机器上使用哪台打印机,然后在该机器上设置一个永久 cookie.

You may rely on cookies. Try to create some form of machine authentication, or better, machine identification page, browse it once from each machine telling the server which is the printer to use on that machine, and then set a permanent cookie on that machine.

只要 cookie 不会被删除(也许您可以随时更新 cookie,您永远不知道...)您就有了一个简单机制.

As soon as cookies won't be deleted (maybe you can always renew the cookie, you never know...) you have a simple mechanism.

这是我能推荐的***的:(

It's the best I can suggest :(