简体   繁体   中英

How do I maintain session in windows forms?

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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