Difference of ViewBag and ViewState in Mvc C #

I want to understand what ViewBag

and are ViewState

, and when each is used. We need to clarify the code.

+3


source to share


2 answers


ViewState is an old classic concept ASP.NET WebForms

where controls and ASPX maintain their state between HTTP requests using a hidden field.



ViewBag is a completely different concept in applications ASP.NET MVC

. It's just a simple container that you can use to pass some data from controller to view. This state does not support HTTP requests.

+2


source


Getting started with your question

In MVC, we don't have a Viewstate. To maintain the values, link below to the link

Keeping browsing in Asp.net mvc?



ASP.NET MVC not working with ViewState and Postback?

we use ViewBag, ViewData, TempData to stream values ​​from controller to view or controller to controller.

+3


source







All Articles