Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.MVC - ViewData

Is ViewData of MVC is equivalent to ViewState Webforms ?

like image 228
prakash Avatar asked Dec 30 '09 18:12

prakash


2 Answers

No ViewData is a collection of information that is used by the Views in ASP.NET MVC. It's a way to pass additional data to a view that is more than the Model for the view contains. ViewData is not sent to the client, it is used by the server when processing the output to send to the client.

ViewState in WebForms is a way to maintain state between postbacks. ViewState is sent between the client and the server.

like image 153
Mark Sherretta Avatar answered Oct 10 '22 07:10

Mark Sherretta


View state is stored on the client and sent back to the server with each request. It is used to add a form of state to your web application.

ViewData is not stored or sent to the client and is used by the server for processing. You can use it to send additional information to your view from the controller.

like image 33
Dan Avatar answered Oct 10 '22 08:10

Dan