The Technology Aces blog is a consolidation of the personal blog posts from the individuals that help make Technology Aces the truly elite IT professionals our clients have come to recognize and depend upon.
For more information about the individual authors please follow the links to their blog. Links can be found in the post details section of each post or in the sidebar navigation located on the left side of this page.
SiteMap Providers
Written By
Mark / October 30 1:20 pm
-
Task
Implement a Microsoft approved strategy with regards to the usage of a sitemap provider allowing for dynamic updates without requiring a restart of the web application.
-
Glossary of Terms
The terms below are intended to provide a basic understanding of common terms and procedures used throughout the remainder of this document.
-
Provider Model – an extensibility model that lets developers pull out and replace the built-in implementations of the core .net framework building block services allowing developers to quickly and easily make use of the rich productivity features.
- Is open source as of asp.net 2.0;
- Is used throughout asp.net;
- Makes asp.net much more flexible, expandable, and customizable;
- Includes, but is not limited to, the following providers: Membership; Role, Site Map, Session State and Profile;
-
Site Map Providers – provide the interface between ASP.NET’s data-driven site-navigation features and site map data sources. The fundamental job of a site map provider is to read site map data from a data source and build an upside-down tree of SiteMapNode objects, and to provide methods for retrieving nodes from the site map.
- Site Map Provider – Defines the basic contract between ASP.NET and site map providers
- Static Site Map Provider – Aids developers in implementing the contract between ASP.NET and site map providers; is the base class for the XmlSiteMapProvider; can be used as the base class for custom site map providers; provider classes that derive from StaticSiteMapProvider require considerably less code than providers derived from SiteMapProvider; The word “Static” in StaticSiteMapProvider refers to the fact that the site map data source is static
MSDN - Inside the ASP.NET Team: ASP.NET’s XmlSiteMapProvider goes to the extra trouble of monitoring the site map file and reloading it if it changes. If site map data is stored in a Microsoft SQL Server database, consider using ASP.NET 2.0’s SqlCacheDependency class to monitor the database for changes.
-
SQL Cache Dependency – Establishes a relationship between an item stored in an ASP.NET application’s Cache object and either a specific SQL Server database table or the results of a SQL Server 2005 query
-
- Can be used with SQL Server 7.0 and later versions
- Can dramatically increase application performance
- Can be used for both the application cache and the page output cache
- You do not need extensive SQL knowledge to configure SQL cache dependency in your application and in SQL Server. ASP.NET includes tools that automate the configuration.
- SQL Server 2005 and later versions implement a change notification model where notifications are sent to subscribing application servers, rather than relying on the polling model required in earlier versions of SQL Server.
-
OPTIONS
-
- Is the default site map provider for ASP.NET
- Folder Site Map Provider – exposes the file system as a data source for site navigation
-
SQL Site Map Provider – site maps stored in databases alongside other content conforming to a particular schema; is a StaticSiteMapProvider-derivative
- Jeff Procise – Contributing editor to MSDN Magazine; Author of several books; Co-founder of Wintellect. In June 2005, Jeff created an article indentifying an alternate solution to the xml site map provider, a new site map provider name SQLSiteMapProvider. In February 2006, Jeff updated his SQLSiteMapProvider to include the usage of the SQLCacheDependency which monitors the site map database and refreshes the site map if changes occur.
- Custom Site Map Provider – As the provider model is open source, one can create any site map provider desired.
-
Lessons Learned
My initial implementation for my application’s site map was the SQL Site Map Provider as identified in section 3.3 (without the utilization of the SQL Cache Dependency class). My initial thought was that additional queries to the database for the site navigation would not impede the performance of the individual pages. It is ironic that this very assumption is what caused my production issue of missing nodes at what seemed to be irregular intervals. Since the SQLSiteMapProvider inherits from the StaticSiteMapProvider, the site map data source is static and is cached by the application. To accommodate for this, the SQLSiteMapProvider provides methods for clearing and querying the site map data source, similar to the XMLSiteMapProvider. These APIs will be entered by many worker threads in parallel in order to serve requests. Clearing the data at the same time the data is being queried is dangerous and prone to causing intermittent failures. By introducing the SQLDependancyCache class, these processes are isolated.
- References
i http://msdn.microsoft.com/en-us/asp.net/aa336558.aspx
ii http://msdn.microsoft.com/en-us/library/aa479033.aspx
iii http://msdn.microsoft.com/en-us/library/aa479033.aspx#aspnetprovmod_prt3_topic1
iv http://msdn.microsoft.com/en-us/library/aa479033.aspx#aspnetprovmod_prt3_topic4
v http://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependency.aspx
vi http://msdn.microsoft.com/en-us/library/ms178604.aspx#sectionToggle0
vii http://msdn.microsoft.com/en-us/library/system.web.xmlsitemapprovider.aspx
viii http://msdn.microsoft.com/en-us/library/aa479338.aspx#extndsi_topic6
ix http://msdn.microsoft.com/en-us/library/aa479033.aspx#aspnetprovmod_prt3_topic5
x http://msdn.microsoft.com/en-us/magazine/cc163787.aspx
xi http://msdn.microsoft.com/en-us/magazine/cc163657.aspx
xii http://msdn.microsoft.com/en-us/magazine/cc164622.aspx?code=true&level=root&file=SqlSiteMapProvider.cs
xiii http://msdn.microsoft.com/en-us/library/aa479320.aspx