如何在 ASP.NET 应用程序中唯一标识客户端计算机? [英] How to uniquely identify the client machine in an ASP.NET application?

查看:23
本文介绍了如何在 ASP.NET 应用程序中唯一标识客户端计算机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在托管环境中运行的服务器应用程序,但在客户端的本地网络中创建打印作业(在 NAT 后面;其机制不相关).

I have a server application that runs in a hosted environment but creates print jobs in the client's local network (behind NAT; the mechanics of this is not relevant).

为了将打印作业发送到连接到工作站的打印机,我需要识别工作站.用户在工作站之间移动,因此我无法将用户与工作站/打印机永久关联.简单的解决方案是要求用户识别他正在登录的机器,例如通过从列表中进行选择,但这很不方便,并且容易出现用户错误.

In order to send the print job to the printer that is attached to the workstation, I need to identify the workstation. The users move around between workstations, so I can't permanently associate a user with a workstation/printer. The trivial solution is to require the user to identify the machine he is logging in from, for instance by selecting from a list, but that's an inconvenience and subject to user error.

我已经消除的选项:

  • 主机头变量(不发送任何可识别的内容)
  • Cookies,支持用户选择.这在一定程度上解决了用户错误的可能性,但不是真的.
  • HTML5 DOM 存储 - 客户端浏览器不支持

还有其他想法吗?

我确实可以选择将此特定功能(创建打印作业)放入胖客户端应用程序中.然后当然可以配置应用程序,问题就会消失.但用户体验会因必须在浏览器和 Windows 应用之间切换而受到影响.

I do have the option of puttnig this particular function (create a print job) into a thick client app. The app can then of course be configured and the problem goes away. But the user experience will suffer from having to switch between the browser and a Windows app.

推荐答案

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

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 :(

这篇关于如何在 ASP.NET 应用程序中唯一标识客户端计算机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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