Do desktop applications need session variables?
I am trying to create an application similar to a quiz engine. I was wondering if I need sessi开发者_JS百科on variables to store information between different pages or I can pull the data directly out of textboxes.I am using C-sharp,dot net and WPF.
You don't need Session
in a Desktop Application. Session is used to maintain/persist state between postbacks in web applications.
In desktop application, you don't do postbacks. You can use a Static Class
to store your data that needs to be shared across multiple windows.
Do you mean session variables like in ASP.NET? I don't think there's any built-in support for session variables in WPF, and I've built many WPF apps without using anything resembling a session variable, so my answer would be "no". And, yes, you can certainly grab data directly from text boxes in WPF.
As far as I know, the purpose of a session variable is to persist data in a web app, which is by its nature "stateless". WPF applications are not stateless, so there's really no reason for a session variable.
A session object exists because HTTP is stateless. In an application you don't need a session because you have access to all/most variables when you need them.
There are no 'page refreshes' in WPF - it's more like WinForms than web page, so you don't have to keep passing values in session.
精彩评论