Hello!
Here are the different kind of state type that can be used for webb forms..
StateType Client or Server Resources
ViewState Client
Cookie Client
Session Server
Application Server
Cache Server
Is it possible to say anything about which of these is best practice to use
?
//Tony
You missed a number out.
I don't really follow how you can read about them but not see how they
would be used.
ViewState
This is the default lazy developer's way of maintaining state on a
form. You should think twice about using a lot of this and it's main
use is for fields you can see on the form. If you need an object
which allows you to tell what the previous state something was before
postback then that's also somewhere you can store an object
conveniently.
If you have to think about which field you're using it on then you
probably ought to be looking at MVC.
Cookie
Allows you to store preferences across sessions because it's on the
client. Downside is your user must be on the same computer or not
care much that they lose their settings.
Session
State which needs to be maintained for that session. Don't store big
objects unless you know there aren't many concurrent users.
Application
Static data - you don't see this used now there's cache.
Cache
Not user specific and you can associate a key. This is great for
reducing load on database servers by caching data which is expensive
to collect off them. BUT you need to invalidate the cache as users
change data or not care that it's stale.