Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is ASP.NET MVC stateless? [closed]

Tags:

c#

asp.net-mvc

I have heard that MVC .NET is stateless. What are the implications of this and why is it that MVC is stateless.

like image 342
Nate Pet Avatar asked Dec 15 '11 20:12

Nate Pet


2 Answers

State is managed in ASP.NET (MVC and WebForms) through several means:

  • Session
  • Cookies
  • Form posts
  • Application
  • Query string
  • Cache
  • Context

MVC eliminates ViewState, which means that controls (text boxes, checkboxes, etc.) lose their values each time a page is posted back. You need to repopulate them manually or through other means (Model binding, for instance).

MVC isn't truly stateless, but it does remove one of the most common ways of persisting state in ASP.NET -- the ViewState.

like image 61
Garrett Vlieger Avatar answered Sep 28 '22 08:09

Garrett Vlieger


MVC is stateless because HTTP is. There is nothing in HTTP that indicates when a session starts or ends.

Every web framework tries to overcome this by using either a cookie or Request/Response features like the query string or FORM post.

like image 29
jgauffin Avatar answered Sep 28 '22 08:09

jgauffin