
Cookies | 341
HttpRequest
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
GetKey(Index)
Returns a string containing the key corresponding to the provided
Index
argument.
With the exception of the Cookies collection, the code used to access keys and
values in the collections the
Request class exposes is nearly identical in every case.
This similarity makes it simple to create your own reusable classes or methods for
manipulating the values from these collections, regardless of which collection you
are working with.
Cookies
HttpCookieCollection = Request.Cookies
The Cookies collection returns an instance of the HttpCookieCollection class
containing all cookies sent as a part of the current request. The
HttpCookieCollection class contains an instance of the HttpCookie class for each
cookie passed as part of the client request. The properties of these HttpCookie
instances can be used to access information about the cookie(s).
As in classic ASP, the Cookies collection is still implemented as a collection (in
fact, the HttpCookieCollection inherits from the .NET
NameObjectCollectionBase
class), but rather than a collection of string keys and string values, the ASP.NET
implementation is a collection of string keys and objects (instances of the
HttpCookie class). Individual cookies are retrieved into variables of type Http-
Cookie, providing ...