This section provides you with a brief introduction to some of the other providers that you can customize. Given what you have learned already about customizing the ProfileProvider, the MembershipProvider, and the RoleProvider, you should have no trouble using that knowledge to create your own custom providers for each of the items discussed in the rest of this section. Introduction to the SessionState ProviderThe session state provider is used to maintain session state for a web application. The session state is essentially a collection of name-value pairs that are associated with a session identifier. This session identifier is stored as a cookie (or embedded in the URL depending on session state configuration) on the client's machine. Each time a user requests a page, the session state for that user is accessible by means of the user's session identifier. To create your own session state provider, you must override the SessionStateProviderBase class in the System.Web.SessionState namespace. The list of methods for that class is shown in Table 29.6.
Introduction to the SiteMap ProviderThe SiteMap Provider is responsible for maintaining a site hierarchy. Essentially it is responsible for storing a tree structure, where each node in the tree has a description of a page as well as a link to that page. Site Map Providers make it possible to create "breadcrumb"-style controls that illustrate where a user is within a site hierarchy. To create your own Site Map Provider, you need to create a class that inherits from System.Web.SiteMapProvider. The good thing about this particular provider is that not only does ASP.NET ship with an XML version, but the XML version is the default. Microsoft has provided an XmlSiteMapProvider that allows you to define your site map within an XML file. However, if you are already storing your site map in a database such as SQL Server or Oracle in your own schema, you might want to create your own provider. Table 29.7 illustrates the methods of the SiteMapProvider class that you must override in order to implement your own custom Site Map Provider.
The basic idea behind the site map provider is that the code is maintaining a tree structure with page-related information. You can come up with a fairly simple schema to manage this. The caveat here is that often many tree structures in relational databases perform slowly, so when implementing your own Site Map provider make sure to take advantage of the Hintxxxx methods and provide very fast (and cacheable) results. |