How do I maintain session in windows forms?

2020-07-22 10:19发布

I want to maintain session on a windows application.

How do I maintain the session of a user like we use in ASP.NET to track the user information?

2条回答
太酷不给撩
2楼-- · 2020-07-22 10:21

If you mean sessions like in asp.net, then there is no need. Windows applications maintain state, unlike web applications.

This does not include shutting down and restarting the application.

查看更多
▲ chillily
3楼-- · 2020-07-22 10:28

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:

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. 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.

查看更多
登录 后发表回答