ASP.NET 2.0 Unleashed
Developers who are new to programming for the web always have difficulty understanding the problem of maintaining state. The HTTP protocol, the fundamental protocol of the World Wide Web, is a stateless protocol. What this means is that from a web server's perspective, every request is from a new user. The HTTP protocol does not provide you with any method of determining whether any two requests are made by the same person. However, maintaining state is important in just about any web application. The paradigmatic example is a shopping cart. If you want to associate a shopping cart with a user over multiple page requests, then you need some method of maintaining state. This chapter looks at three methods included in the ASP.NET 2.0 Framework for associating data with a particular user over multiple page requests. In the first section, you learn how to create and manipulate browser cookies. A browser cookie enables you to associate a little bit of text with each website user. Next, you learn how to take advantage of Session state. Session state enables you to associate an arbitrary object with any user. For example, you can store a shipping cart object in Session state. You learn how to take advantage of cookieless Session state so that you can use Session state even when a browser has cookies disabled. You also learn how to make Session state more robust by enabling out-of-process Session state. Finally, we examine a new feature introduced with the ASP.NET 2.0 framework: the Profile object. The Profile object provides you with a method of creating a strongly typed and persistent form of session state. You learn different methods of defining a profile. You also learn how to use the Profile object from within a component. Finally, you learn how to implement a custom Profile provider. |
Категории