使用网络数据库时在哪里存储用户 ID

发布于 2024-12-01 00:53:00 字数 265 浏览 0 评论 0原文

我们有一个使用网络数据库的 C#.Net 应用程序。我的意思是应用程序的许多实例将从不同的机器访问相同的数据库。那么,如果我必须存储用户 ID 以在重新登录时向用户显示,我可以将其存储在哪里?

我的选择是:
- 将其存储在应用程序目录中的本地文件中。 (但问题是应用程序是使用 Click Once 安装的。更新应用程序时,应用程序目录正在更改。可能我在这里遗漏了一些东西。)
- 存储在注册表中。
还有其他的吗?

有人可以建议该怎么做吗?如果我错了请纠正我。

We have a C#.Net application which uses a network database. I mean to say that many instances of the application will access the same db from different machines. So if I have to store the user-id to show the user while re-logging in, where can I store it?

The options i have are:
- Storing it in a local file in application directory. (But the problem is that the application is installed using Click Once. When the application is updated the application directory is being changed. May be I am missing something here.)
- Storing in the registry.
Are there any other?

Can some one please suggest what to do? Correct me if I am wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夏尔 2024-12-08 00:53:00

有此类内容的内置位置,请参阅 环境 - 具体来说:

  • ApplicationData(用户特定的漫游)
  • LocalApplicationData(用户特定的非漫游)
  • CommonApplicationData (不是用户特定)

There are buil-int locations for this kind of stuff see Environment - specifically:

  • ApplicationData (user-specific roaming)
  • LocalApplicationData (user-specific non-roaming)
  • CommonApplicationData (not user-specific)
悲喜皆因你 2024-12-08 00:53:00

通常,您希望存储需要在会话之间保留的任何数据,并且这些数据是注册表或用户 AppData 文件夹中特定于用户的数据。通常对于小事情(即 id、基本设置等),注册表是最好的地方。只需确保将其粘贴在 HKCU\Software\您的公司名称\您的程序名称下即可。尽管如果数据是敏感的,您应该小心放置它的位置,并且应该对其进行加密以防止基本的窥探。如果它是不敏感的数据,那么注册表是放置它的好地方。

当然,这假设安装和配置不需要是 xcopy 可移植的(即用户只需将安装文件夹复制到新位置/计算机即可让一切正常工作)。如果是这种情况,那么您需要将其存储在安装目录下。

Generally you want to store any data that needs to persist between sessions, and is user specific in the registry, or the user AppData folder. Normally for small things (i.e. ids, basic settings etc....) the registry is the best place. Just make sure to stick it under HKCU\Software\Your company name\your program name. Although if the data is sensitive you should be careful where you place it, and it should be encryptedto protect it from basic snooping. If it's data that isn't sensitive though then the registry is a good place to put it.

This assumes of course that the installation and configuration doesn't need to be xcopy portable (i.e. a user could just copy the installation folder to a new place/computer and have everything work as normal). If that's the case then you'll want to store it under the installation directory.

风吹雨成花 2024-12-08 00:53:00

如果您需要将 UserID 存储在本地,请将其保存在某种配置文件中,可能位于“LastLogin”条目下。查看这个问题,特别是此答案了解更多信息。

If you need to store the UserID on the local, keep it in some kind of configuration file, mabe under a "LastLogin" entry. Check out this question and specifically this answer for more information.

兮颜 2024-12-08 00:53:00

考虑使用隔离存储

Consider using Isolated Storage

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文