Which type state is more relevant to use thyen other

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

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

type where scope

ViewState client page
Cookie without expiration client session
Cookie with expiration client user
Session server session
Application server application
Cache server application

My suggestion is:

you need page scope => use view state
you need user scope => use cookie with expiration
you need sessions scope => use session
you need application scope => use cache

The first two are obvious.

For session scope then I can't see any reason to send cookies
forth and back.

For application scope then caches offers more options.

Arne
 
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.
 
Back
Top