- Understanding How Web Forms Are Processed
- Performing Basic State Management in Web Applications
- Using Cookies
- Using Hidden Fields and Query Strings
- Working with the Session Object
- Working with the Application Object
- Setting Up Global Objects with the global.asax File
- Configuring the Application
- Summary
- Q&A
- Workshop
Performing Basic State Management in Web Applications
Most Web applications are customized for each individual site user. Even if the site behaves the same way for every user, a user will often perform an operation on the site that spans two or more pages. For instance, if your Web application has a search feature, you might use one page to gather a search string. You might use a second page to display the results and a third page to hold a history of search queries. Designing your ASP.NET code to keep track of search queries, search results, and search history entries involves state management. In the broadest terms, state management refers to the ways an ASP.Net page "remembers" what a user has done previously.
If the searching feature was part of a standalone program, such as a Visual Basic Windows application, storing the user's state, including search queries and results, isn't an issuejust store the search strings and results on the client computer. With Web applications, you can't store much of anything on the client computer because the client is just a Web browser.
Web programmers have invented a number of methods for storing state in Web applications. The most basic methods include cookies, query strings, and hidden fields. These methods allow you to store a small bit of information, such as a key to a database table.
By using ASP.NET, you have these and several other more powerful state options at your disposal. These methods include the Session and Application objects and the ViewState property. ASP.NET also adds a new class for page caching, Response.Cache. You can use this feature to achieve significant performance improvements in your Web applications, usually after the bulk of coding is complete. Page caching will be explained in more detail on Day 7.