您也可以将 Settings.Settings 文件用于 ASP.Net 站点吗?
我有一个已用作 ASP.Net Web 应用程序的代码库。 它现在正在扩展并用作两个 WinForms 应用程序的一部分。
主要区别在于 WinForms 应用程序应存储“每个用户”的设置,而 Web 应用程序仅需要存储“应用程序”级别的设置。 它们是相同的设置,但根据应用程序的类型以不同的方式存储。
澄清:相同的代码将用作网站应用程序的基础以及桌面应用程序的代码库。 在桌面应用程序中,设置应存储在适当的用户目录中,但当相同的代码运行 Web 应用程序时,这是行不通的。 因此陷入了困境。 如何从 Web 应用程序的 web.config 类型情况切换到桌面应用程序的 user.config 类型情况(存储在正确的目录中)。
有谁知道 settings.settings 文件是否适用于网络应用程序?
有没有更好的方法以两种不同的方式存储相同的设置?
I have a code base that has been used as an ASP.Net web application. It's now branching out and being used as part of two WinForms applications.
The main difference is that the WinForms apps should store their settings "per user" and the web app only needs to store the settings at the "application" level. They are the same settings, but stored differently depending on type of application.
Clarification: The same code will be used as the foundation for a web site application as well as the code base for a desktop application. In the desktop application the settings should be stored in the appropriate user directory, but that's not workable when the same code is running the web app. Hence the dilemma. How to switch from a web.config-type situation for the web app to a user.config-type situation (stored in the proper directory) for the desktop app.
Does anyone know if the settings.settings file is workable for a web app?
Is there a better way to store the same settings in two different ways?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您可以将 Settings.Settings 文件用于 Web 应用程序项目。 就像在 WinForms 项目中一样进行设置。 对于 Web 项目,您仅限于应用程序范围 - 您无法创建用户范围的设置。
Yes, you can use Settings.Settings files for web application projects. Set it up just like in your WinForms projects. With a web project, you are limited to Application scope though - you cannot create user-scoped settings.
在不了解有关您的应用程序的更多详细信息的情况下 - 也许存储用户数据(或其他一些集中存储库)是最好的。 然后用户可以选择任一平台并访问他们的偏好和设置。
Without knowing more details about your app - perhaps storing the user data (or some other centralized repository) would be best. Then users could chose either platform and have access to their preferences and settings.