Value cannot be null. Parameter name: source

Jul 24, 2010 at 2:54 PM

Hi!

I am trying to get MVC sitemap provider work but there is something it cannot handle. Here is my sitemap definition:

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
  <mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
    <mvcSiteMapNode title="Browse Store" controller="Contacts" action="Index" />
    <mvcSiteMapNode title="Sales" clickable="false">
      <mvcSiteMapNode title="Testing" clickable="false" />
      <mvcSiteMapNode title="Price Enquiries 2" area="Sales" controller="PriceOffer" action="Index" />
    </mvcSiteMapNode>
  </mvcSiteMapNode>
</mvcSiteMap>

All controllers, areas and actions provided here work as expected. I can insert URL- manually to browser and view open without any problems.

When I try to let generate sitemap using SiteMap() method I get the following exception:

[ArgumentNullException: Value cannot be null.
Parameter name: source]
   System.Linq.Enumerable.Count(IEnumerable`1 source) +4164811
   MvcSiteMapProvider.DefaultControllerTypeResolver.ResolveControllerType(String areaName, String controllerName) +125
   MvcSiteMapProvider.AuthorizeAttributeAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) +127
   MvcSiteMapProvider.DefaultAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) +149
   MvcSiteMapProvider.DefaultSiteMapProvider.IsAccessibleToUser(HttpContext context, SiteMapNode node) +24
   System.Web.SiteMapNode.IsAccessibleToUser(HttpContext context) +17
   System.Web.StaticSiteMapProvider.GetChildNodes(SiteMapNode node) +378
   System.Web.SiteMapNode.get_ChildNodes() +30
   System.Web.SiteMapNode.get_HasChildNodes() +10
   MvcSiteMapProvider.Web.Html.SiteMapHelper.SiteMap(MvcSiteMapHtmlHelper helper, SiteMapNode rootNode, String cssClass, Boolean renderListTag) +523
   MvcSiteMapProvider.Web.Html.SiteMapHelper.SiteMap(MvcSiteMapHtmlHelper helper) +28
   ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\plah\plah\Web\Views\Shared\Site.Master:157
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +56
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060

Line nr. 157 in Site.Master is as follows:

<%= Html.MvcSiteMap().SiteMap() %>

If I remove the last node from sitemap (Price Enquiries 2) then there is no exception and sitemap is written out. I mention again: parameters are correct because I am able to open view directly from browser.

Jul 24, 2010 at 3:07 PM

Last version from code repository has no problems with this sitemap, so I consider this problem solved and compile my sitemap using latest source.

Coordinator
Jul 25, 2010 at 12:50 PM

Ok, thanks for letting me know.