I'm trying to build an ASP site map dynamically to provide to Google Webmaster Tools. I believe I have it finished and am trying to test it...but I can't for the life of me figure out how to navigate to my sitemap. xD
I've built a class that extends StaticSiteMapProvider
and referenced it in my web config.
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public class SiteMapConfig : StaticSiteMapProvider
{
SiteMapNode _root;
ArticleRepository _articles = new ArticleRepository();
OpportunityRepository _opportunities = new OpportunityRepository();
public override SiteMapNode BuildSiteMap()
{
lock (this)
{
var root = GetRootNodeCore();
var newsNode = new SiteMapNode(this, "News", "~/News/", "News");
this.AddNode(newsNode, root);
foreach (var article in _articles.GetAll())
{
var encodedTitle = URLEncoding.MakeUserFriendlyURLValue(article.Title);
var articleNode = new SiteMapNode(this, "Article:" + article.ID, "~/News/" + article.ID + "/" + encodedTitle + "/", article.Title);
this.AddNode(articleNode, newsNode);
}
var gamesNode = new SiteMapNode(this, "Games", "~/Games/", "Games");
this.AddNode(gamesNode, root);
var aboutNode = new SiteMapNode(this, "About", "~/About/", "About");
this.AddNode(aboutNode, root);
var OpportunitiesNode = new SiteMapNode(this, "Opportunities", "~/Opportunities/", "Opportunities");
this.AddNode(OpportunitiesNode, root);
foreach (var opportunity in _opportunities.GetAll())
{
var encodedTitle = URLEncoding.MakeUserFriendlyURLValue(opportunity.Title);
var opportunityNode = new SiteMapNode(this, "Opportunity:" + opportunity.ID, "~/Opportunity/" + opportunity.ID + "/" + encodedTitle + "/", opportunity.Title);
this.AddNode(opportunityNode, OpportunitiesNode);
}
}
return _root;
}
protected override SiteMapNode GetRootNodeCore()
{
if (_root == null)
{
_root = new SiteMapNode(this, "Home", "~/", "[REDACTED]");
this.AddNode(_root);
}
return _root;
}
}
Web.Config
:
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<!-- TW: Added to configure site map -->
<siteMap enabled="true" defaultProvider="SiteMapConfig">
<providers>
<clear />
<add name="SiteMapConfig" type="Daemon.Sites.Company.SiteMapConfig, Daemon.Sites.Company" />
</providers>
</siteMap>
How can I see this in xml form?
Is there another step that isn't mentioned in all of my examples? (Example 1, Example 2, Example 3)
I've tried: "~/Sitemap", "~/Web.sitemap", "~/sitemap.txt"