System.Web.Mvc.UrlParameter Appearing in Generated Sitemap.xml

Dec 13, 2010 at 12:15 PM

I've been setting up a large site to use the ASP.NET MVC Sitemap provider using DynamicNodes, and the breadcrumbs and html sitemaps are all working ok with the correct urls.

But when I add the code to the global.asax file to create the sitemap.xml when visiting that url the urls created in the xml are no the same as in the breadcrumbs and html sitemaps and include "System.Web.Mvc.UrlParameter" instead of just ignoring the parameter.

Examples of the urls we have are:

/news/2010/08/12 - Is the full url

/news/2010/08 - This is the correct url, but in the sitemap.xml it produces - /news/2010/08/System.Web.Mvc.UrlParameter.

Is there a problem somewhere or do I need to change the code/settings somewhere to stop it displaying this?

Also the top url on the sitemap.xml also has the following extra text - ?visibility=SiteMapHelper%2C!*

As mentioned above the provider works ok without any problems for the breadcrumb and html sitemap, this just occurs in the sitemap.xml that is generated.

Coordinator
Dec 21, 2010 at 12:55 PM
Edited Dec 21, 2010 at 12:56 PM

Try setting the attributesToIgnore attribute in web.config. Also see http://mvcsitemap.codeplex.com/Thread/View.aspx?ThreadId=238738

Dec 21, 2010 at 1:06 PM

Hello,

I've already tried this and this doesn't remove the extra text in the sitemap.xml.

Also this is not what is causing the problem with the UrlParameter appearing

Coordinator
Dec 22, 2010 at 6:02 AM

Can you post your mvc sitemap file + routes?

Dec 22, 2010 at 2:29 PM

This is the mvc sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
    <mvcSiteMapNode title="SiteTitle" visibility="SiteMapHelper,!*" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal" lastModifiedDate="2002-05-30T09:00:00">
        <mvcSiteMapNode dynamicNodeProvider="Website.Code.NewsArticlesDynamicNodeProvider, Website" />
        <mvcSiteMapNode dynamicNodeProvider="Website.Code.EventsDynamicNodeProvider, Website" />
</mvcSiteMapNode>
</mvcSiteMap>

and this is the route we have for the news articles:

            routes.MapRoute(
                "NewsArticle", // Route name
                "news/{year}/{month}/{day}/{articleUrl}", // URL with parameters
                new { controller = "News", action = "Article" }  // Parameter defaults
            );