简体   繁体   English

如何在Windows窗体中维护会话?

[英]How do I maintain session in windows forms?

I want to maintain session on a windows application. 我想在Windows应用程序上维护会话。

How do I maintain the session of a user like we use in ASP.NET to track the user information? 如何维护用户的会话,就像我们在ASP.NET中用来跟踪用户信息一样?

If you mean sessions like in asp.net, then there is no need. 如果你的意思是像asp.net这样的会话,那就没有必要了。 Windows applications maintain state, unlike web applications. Windows应用程序维护状态,与Web应用程序不同

This does not include shutting down and restarting the application. 这不包括关闭和重新启动应用程序。

If you mean, how one can serialize program settings the user has done using your app, and you want to restore them after the program has restarted, an easy way is the built in settings-management . 如果您的意思是,如何序列化用户使用您的应用程序完成的程序设置,并且您希望在程序重新启动后恢复它们,一种简单的方法是内置的设置管理 This works with WinForms and WPF: 这适用于WinForms和WPF:

In VS under properties, you can define all settings that in the app are used (inclusive data-type) and then you can set and get values over the Properties.Settings.Default -Property. 在VS属性下,您可以定义应用程序中使用的所有设置(包含数据类型),然后您可以在Properties.Settings.Default -Property上设置和获取值。 Please note that there exists two type of settings: Application and User . 请注意,存在两种类型的设置: 应用程序用户 The one you will need to save "session"-state of your user, is User . 用户需要保存“会话”状态的用户

See here for more information about saving settings in .net windows applications. 有关在.net Windows应用程序中保存设置的详细信息,请参阅此处

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

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