Learn what state is and how you use it
Learn different methods of state management
Learn the advantages and disadvantages of each method
Web pages are, by definition, stateless. This means that as you move from page to page, the data from each page is automatically discarded. Because you might need data from one of these previous pages, you need to store that data (or state) as you move from one page to another. There are many techniques you can use to maintain state. Programmers today use Session variables, XML files, databases, and many other proprietary solutions.
State management capabilities are very primitive in ASP when compared to ASP.NET. In ASP, the Session object can only run in-process with the IIS server and does not have any Web farm capabilities. If you want to use a Web farm with ASP, you are forced to create some sort of COM component to store the state into a SQL Server database. You are able to use hidden input fields, but you don't get the automatic state management provided by the ViewState object, and you have to manage it all manually. Also, there are no built-in StateBag objects, so any state you need to keep while on a page has to be managed in hidden input fields, and you have to handle the encryption yourself.
In this chapter, you will learn how to use the various state-management techniques in your .NET Web applications. You will see how to use the Session object, StateBag objects, and the .NET Framework to manage state across a Web farm. You will also learn the advantages and disadvantages of each of these techniques.