An alternative way to refresh SiteMap with SQLSiteMapProvider

by lichen 2/12/2006 2:34:00 PM

I implemented a SiteMap that was extended from SQLSiteMapProvider in Jeff Prosise's MSDN article. Jeff Prosise used SQLServer Notification as a mechanism as to refresh the SiteMap. After I changed the stored procedure to use the Common Table Expression, I found that I freqently receive unwanted notification that cleared my sitemap. Since the SiteMap table is managed by a content management system, I decided to implement an alternative way to refresh the sitemap.

The way is to change the SQLSiteMapProvider to implement an IRefreshable interface:

public interface IRefreshable

{

void Refresh();

}

 

In my CMS code, I then call the Refresh method to refresh the sitemap:

IRefreshable siteMapProvider = SiteMap.Provider as IRefreshable;

if (siteMapProvider != null)

{

siteMapProvider.Refresh();

}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.Net | ASP.NET

Related posts

Comments

2/26/2006 10:09:00 PM

Greg

i'm interested in how you implemented this. I'm pretty new with ASP.NET and have implemented the SQLSiteMap Provider (using MySQL 5.0) and works fine so far. Except same issue with database changes don't show up on the sitemap, unless I resave the files. When you put the "Public Interface IRefreshable" into the SQLSiteMap Provider, did you just add those lines or what did you have to change? Also in you CMS how are you calling the refresh method.
Thanks

Greg us

2/28/2006 5:26:00 PM

Li Chen

What I did was in the code that save the changes to CMS, I use the above code to Refresh the siteMapProvider.

Li Chen us

3/6/2006 10:32:00 AM

Pether

Do you know why the siteMap clears? I have that problem, that my menues suddenly dissapeare at PostBack. Thought that it might be the same problem as you had...

Pether us

3/11/2006 3:37:00 PM

Li Chen

I had similar problem when I turned on SQL Server Notification. When I set a break points in the program, I found SQL Server Notification fired for no reason right after the SQLSiteMap provider read the site map in and clear the site map. I could not use it in a predictive way. That is why I went to this alternative way to refresh my sitemap.

Li Chen us

3/22/2006 3:22:00 PM

ghozy

I just added a Public Refesh method to the SQLSiteMapProvider Class. So I can refesh whenver i want.
addition to the class (C#):
public void Refresh()
{
Clear();
_nodes.Clear();
_root = null;
}

that how i refesh SiteMap in my code(VB.NET):
Dim SiteMapProv As SqlSiteMapProvider = SiteMap.Provider
SiteMapProv.Refresh()

ghozy us

Comments are closed

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Pages

    Recent comments

    Authors

    Tags

      Disclaimer

      The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

      © Copyright 2010

      Sign in