Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I had read that MVC is stateless.
Now i found the meaning of stateless that, If the user requests the same page again, the server repeats the entire sequence, reprocessing the page from scratch. Put another way, a server has no memory of pages that it has processed—page are stateless. Therefore, if an application needs to maintain information about a page.

but still i am confused. Not getting idea.
If MVC is stateless then session variable is not available in MVC?
Or session variable and stateless is different?

Thanks,
Viprat
Posted

Http is stateless by definition.
Even if classic asp.net claims to be statefull, it is simulating state by storing some state information and sending it from client to server and back. Actually the IIS + ASP.NET processing pipeline is more complicated to declare it statefull or stateless, since there are application objects that persist between several calls. But this is highly configurable and depends on many things.

Session is of course there in MVC also, and that's the primary storage of volatile data to be passed between calls, that we don't want to persist.

Believe me, the MVC approach is the canonical one, the ASP.NET classic approach was an interesting but very unique approach.

If you want to get an insight in ASP.NET pipeline check this article: http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp[^]
 
Share this answer
 
v2
MVC is stateless because HTTP is. There is nothing in HTTP that indicates when a session starts or ends.

[Moved From 2nd answer]
They are stateless in the sense that you can never know when the user stops using your site or that the session is lost if the browser fails to transport your state parameters. Compare with FTP or IRC. They have built in session support. Try maintaining state without cookies. It's possible but ugly (the user can just remove any query string parameter or the viewstate from the POST). It's still valid HTTP, but the session will be lost
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900