开发者

ASP.MVC - ViewData

开发者 https://www.devze.com 2022-12-15 16:07 出处:网络
Is Vi开发者_C百科ewData of MVCis equivalent toViewState Webforms ?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 Vi开发者_C百科ewData of MVC is equivalent to ViewState Webforms ?


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.


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.


Not really, since ViewState is persisted in a form field and ViewData is not. So, if you put something in the ViewData when a page is requested, then expect your controller to be able to get it back when a form on that page is posted, it won't be there. With ViewState, it would be.


Not exactly - mvc is stateless in theory - but they have some similarities in use. Could you clarify what your question actually is?

0

精彩评论

暂无评论...
验证码 换一张
取 消