- Day 3: Using Web Forms
- 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
Workshop
The workshop provides quiz questions to help you solidify your understanding of the material covered today as well as exercises to give you experience using what you have learned. Try to understand the quiz and exercise before continuing to tomorrow's lesson. Answers are provided in Appendix A, "Answers to Quizzes and Exercises."
Quiz
-
What is a postback, and when is it used in ASP.Net Web forms?
What are the five different ways of handling state in ASP.Net Web forms?
Where are cookies stored, and what kinds of data can they contain?
Why would you store an object in Application state instead of session state?
How do you change the timeout for a Session object?
What events does the HttpSession class support?
What file do you use to handle Session and Application events?
What tag do you use to declare an object in the global.asax file?
What file do you use to configure a Web application?
What method do the .NET collection classes use to return thread-safe versions of themselves?
Exercises
-
Create a new Web service using Visual Studio. What files did Visual Studio create that we didn't in today's examples?
Add a method called Clear to the MyClass.cs application. How can you ensure that the method is thread-safe?
Create a two-page Web application that allows a user to log on and then select her favorite football team. Save the user's response in a cookie so that subsequent uses of the application will remember the user's preference.