What are the advantages and disadvantages of viewstate ?



What are the advantages and disadvantages of viewstate ?..

Answer / surendra singh

The primary advantages of the ViewState feature in ASP.NET are:
1. Simplicity. There is no need to write possibly complex code to store form data between page submissions.
2. Flexibility. It is possible to enable, configure, and disable ViewState on a control-by-control basis, choosing to persist the values of some fields but not others.
There are, however a few disadvantages that are worth pointing out:
1. Does not track across pages. ViewState information does not automatically transfer from page to page. With the session
approach, values can be stored in the session and accessed from other pages. This is not possible with ViewState, so storing
data into the session must be done explicitly.
2. ViewState is not suitable for transferring data for back-end systems. That is, data still has to be transferred to the back
end using some form of data object.
Describe session handling in a webfarm, how does it work and what are the limits ?
ASP.NET Session supports storing of session data in 3 ways, i] in In-Process ( in the same memory that ASP.NET uses) , ii] out-of-process using Windows NT Service )in separate memory from ASP.NET ) or iii] in SQL Server (persistent storage). Both the Windows Service and SQL Server solution support a webfarm scenario where all the web-servers can be configured to share common session state store.

1. Windows Service :
We can start this service by Start | Control Panel | Administrative Tools | Services |. In that we service names ASP.NET State Service. We can start or stop service by manually or configure to start automatically. Then we have to configure our web.config file

<CONFIGURATION><configuration>
<system.web>
<SessionState
mode = “StateServer”
stateConnectionString = “tcpip=127.0.0.1:42424”
stateNetworkTimeout = “10”
sqlConnectionString=”data source = 127.0.0.1; uid=sa;pwd=”
cookieless =”Flase”
timeout= “20” />
</system.web>
</configuration> </SYSTEM.WEB>
</CONFIGURATION>
Here ASP.Net Session is directed to use Windows Service for state management on local server (address : 127.0.0.1 is TCP/IP loop-back address). The default port is 42424. we can configure to any port but for that we have to manually edit the registry.
Follow these simple steps
- In a webfarm make sure you have the same config file in all your web servers.
- Also make sure your objects are serializable.
- For session state to be maintained across different web servers in the webfarm, the application path of the web-site in the IIS Metabase should be identical in all the web-servers in the webfarm.
Which template must you provide, in order to display data in a Repeater control ?
You have to use the ItemTemplate to Display data. Syntax is as follows,
< ItemTemplate >
< div class =”rItem” >
< img src=”images/<%# Container.DataItem(“ImageURL”)%>” hspace=”10” />
< b > <% # Container.DataItem(“Title”)%>
< /div >
< ItemTemplate >

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

Difference between ByVal and ByRef?

2 Answers   Microsoft,


What is Bundling and Minification in MVC?

0 Answers   HCL,


What are the differnt types of handler in ASP.NET?

0 Answers   Sans Pareil IT Services,


How many types of server controls do we have?Also explain differance between them taking an example of ASP.NET?

0 Answers  


What is work flow gen? how can it will work with .Net?

0 Answers   TCS,






What is asynchronous call?

0 Answers  


Difference between .NET components and COM components?

2 Answers   Microsoft,


Explain client side state management system.

0 Answers  


Explain the advantages of asp.net.

0 Answers  


How we implement web farm and web garden concept in asp.net?

0 Answers  


What is Web Application?

2 Answers   HCL,


What is state management techniques in asp.net?

0 Answers  


Categories