1
Vote

Can't see detail view of posts linked on home page

description

When I add a new post to the site and then click the link for said post on the front page, I get an 404. This is cause due to the fact that the root folder in the Provider cannot match the requesting url. Look at the following code snippets.
 
Init function from SiteMapProvider
 
    public override void Initialize(string name, NameValueCollection attributes) {
        base.Initialize(name, attributes);
 
        if (String.IsNullOrEmpty(attributes["rootFolder"]))
            throw new ConfigurationException("Required attribute 'rootFolder' not found (ViNull.Providers.PostSiteMapProvider)");
        if (String.IsNullOrEmpty(attributes["title"]))
            throw new ConfigurationException("Required attribute 'title' not found (ViNull.Providers.PostSiteMapProvider)");
 
        rootFolder = "~/" + attributes["rootFolder"];
        rootNode = new SiteMapNode(this, name + "Root", rootFolder + "/Default.aspx", attributes["title"]);
        isDirty = true;
    }
 
** Notice the value of the root folder.
 
This is a snippet from the global.asax
 
    foreach (var p in SiteMap.Providers) {
        ViNull.Providers.PostSiteMapProvider psmp = p as ViNull.Providers.PostSiteMapProvider;
        if (psmp != null && url.StartsWith("/" + psmp.rootFolder.ToLower() + "/") && !url.Equals("/" + psmp.rootFolder.ToLower() + "/default.aspx"))
            HttpContext.Current.RewritePath("~/" + psmp.rootFolder + "/Template.aspx", false);
    }
 
Since the root folder will always be "~/somevalue" and is contacted w/ "/", it will never match the url.StartsWith function.

comments