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

When using the Pager object, inorder to know which page to go, which property you have to set to grid?

0 Answers   Siebel,


Difference between Array and ArrayList? How Array is benifitful than ArrayList?

3 Answers   Tech Mahindra,


What are the different method of navigation in asp.net?

0 Answers  


What is asp.net with mvc? : Asp.Net MVC

0 Answers  


What is DTS package?

2 Answers   Accenture, TCS,






What is MSIL?

4 Answers  


List of words of preprocessor in .net?

0 Answers  


what is dumpbin.exe?

1 Answers  


What is boxing and how it is done internally?

1 Answers   Microsoft,


what is session,cokkies in asp.net??

5 Answers  


Can we Run the Application without Build

3 Answers   Emphasis,


Explain the difference between the web config and machine config.

0 Answers  


Categories