एमएसडीएन पत्रिका से जेफ प्रोोजिस संस्करण बहुत अच्छी तरह से काम करता है, लेकिन इसमें कुछ त्रुटियां हैं:
AddNode
freaks out with links to external sites on your menu (www.google.com, etc.)
यहां BuildSiteMap()
में मेरा फ़िक्स है:
SiteMapNode node = GetSiteMapNodeFromReader(reader);
string url = node.Url;
if (url.Contains(":"))
{
string garbage = Guid.NewGuid().ToString(); // SiteMapNode needs unique URLs
node.Url = "~/dummy_" + garbage + ".aspx";
AddNode(node, _root);
node.Url = url;
}
else
{
AddNode(node, _root);
}
SQLDependency
caching is cool, but if you don't want to make a trip to the DB everytime your menu loads (to check to see if the dependency has changed) and your menus don't change very often, then why not use HttpRuntime.Cache
instead?
public override SiteMapNode RootNode
{
get
{
SiteMapNode temp = (SiteMapNode)HttpRuntime.Cache["SomeKeyName"];
if (temp == null)
{
temp = BuildSiteMap();
HttpRuntime.Cache.Insert("SomeKeyName", temp, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration);
}
return temp;
}
}