Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Asp.net MVC really eliminates viewstate?

One of the main problems with ASP.net webforms is the viewstate mechanism, which takes a lot of bandwith because he serializes all the form inputs and sends it on post commands.

In the book i'm reading it's mentioned that one of the main virtuous of MVC over webforms is that mvc does not contain viewstate. It's sound pretty cool but from what i'm seeing, mvc also sends all the inputs on post commands (this is the only way he can use his binding mechanism).

so what is the difference ? you can call it view state , you can call it "binding" , but bottom line both MVC and webforms serialize all the inputs and sends them all on POST.

Am i wrong ? if not, what is the difference ?

like image 388
OopsUser Avatar asked Dec 27 '22 20:12

OopsUser


1 Answers

Big difference. Viewstate can get quite large. It retains values which are not necessarily contained in form data. Think of GridViews and Label's etc. They aren't in input fields yet they get persisted through ViewState. In MVC there really is no concept of persistence. It's up to you to return the data to the view (although the binding mechanism makes this fairly easy to do)

like image 84
ek_ny Avatar answered Feb 17 '23 14:02

ek_ny