I have a Web Application that I have inherited it contains a page that decides which URL you need to visit based upon the state of an object passed into it.
The URL’s are held within the sitemap and there is a method to retrieve all of them.
private Dictionary<string, string> GetUrls() {
var urls = new Dictionary<string, string>();
var provider = SiteMap.Provider;
var page1 = provider.FindSiteMapNodeFromKey("page1");
var page2 = provider.FindSiteMapNodeFromKey("page2");
if (page1 == null || page2 == null)
{
throw new ApplicationException("Pages not found in sitemap");
}
urls["page1URL"] = page1.Url.ToString(CultureInfo.InvariantCulture);
urls["page2URL"] = page2.Url.ToString(CultureInfo.InvariantCulture);
return urls;
}
unfortunately within this method, page1 and page2 are always null
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" enableLocalization="true">
<siteMapNode resourceKey="Concessions" rule="AllowRead">
<siteMapNode url="/page1.aspx" resourceKey="page1" rule="AllowAuthorised"/>
<siteMapNode url="/page2.aspx" resourceKey="page2" rule="AllowAuthorised"/>
</siteMapNode>
</siteMap>
I have tried to debug through this process but I am not getting anywhere near the problem.
So to recap I need this method to return the URLS of the pages defined within the sitemap.
Completely unrelated error, sorry for wasting your time