Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of viewstate in ASP.net MVC [closed]

In asp.net pages, during postback, ViewState makes the data persistent. What makes the data persistent in ASP.net MVC?

like image 998
RandomUser Avatar asked May 13 '14 05:05

RandomUser


People also ask

Is there ViewState in MVC?

ASP.NET MVC does not use ViewState in the traditional sense (that of storing the values of controls in the web page). Rather, the values of the controls are posted to a controller method.

What is ViewState in ASP.NET MVC?

View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.

What is partial view in ASP.NET MVC?

A partial view is a Razor markup file ( . cshtml ) without an @page directive that renders HTML output within another markup file's rendered output. The term partial view is used when developing either an MVC app, where markup files are called views, or a Razor Pages app, where markup files are called pages.

How do you manage states in ASP.NET MVC application?

HTTP is a stateless protocol. Each HTTP request does not know about the previous request. If you are redirecting from one page to other pages, then you have to maintain or persist your data so that you can access it further.

What is the MVC VIEWSTATE equivalent of ASP web forms?

The MVC tries to apply the concept of Http protocol statelessness!! So there should be no viewstate equivalent to that of the asp web forms. However in single page application, aka SPA : you use java script library on client to manage the page and contact the server using Ajax! So it gives the impression.

What is view state in ASP NET?

This article describes ASP.NET view state and shows with an example how view state works in ASP.NET. View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique.

Is it possible to combine VIEWSTATE with MVC?

The ViewState is part of the WebForms framework, which you can combine with MVC. But ViewState is only available for .NET itself, not the .NET Core and other variants. The ViewState data depends on the Control.EnableViewState Property of any Control class that is used with WebForms. Is asp.net MVC really difficult?

What is VIEWSTATE in Salesforce?

The ViewState property is a dictionary that contains key/value pairs that contain the view state data. It is easy for a malicious user to see and modify the contents of a hidden field. For more information about how to secure view state data, see Securing View State later in this topic.


1 Answers

In Asp.Net we have Runat="Server" to make controls like Textbox,Checkbox... into asp.net controls which they run at server and they can maintain viewstate because of they are server controls.

Http is Stateless:

Http is stateless i.e; for it forgets the controls value (like Textbox,Checkbox) for every request that means it doesnt maintain state.To make stateful we use state management techniques like ViewState,Querystring,Sessions,Cookies in Asp.Net.

Coming to your Question

In MVC we dont have Viewstate.In order to maintain the values refer below link

Maintaining viewstate in Asp.net mvc?

ASP.NET MVC doesn't work with ViewState and Postback?

we use ViewBag,ViewData,TempData for the flow of values from controller to view or controller to controller .

like image 142
Ajay Avatar answered Oct 12 '22 01:10

Ajay