Cybercrux

Everything is achievable through technology

States

What’s the difference between stateful and stateless?

Stateless means that HTTP doesn’t have built in support for states. i.e. you can’t store if a user have logged in or done something else.

The most common solution is to use sessions to overcome that problem. This means that you have to be able to include a session identifier in each response or request. It’s either done by creating a session cookie or by including the session identifier in all links.

WebForms tried to make all that transparent (using ViewState) while MVC forces you to handle it manually.

In your example you mentioned buttons and textboxes. The easiest way to let them maintaining their state is simply to stop posting back the entire page. MVC got excellent support for ajax (through jQuery) and I suggest that you use ajax if you just want to do something on the current page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s