0
votes

MvcSiteMapProvider v4 upgrade from v3.

I have a route like

routes.MapRoute(
    "SEPageNoAction",
    "{controller}/{name}/{id}", 
    new { controller = "Home", action = "Index", name = UrlParameter.Optional, id = UrlParameter.Optional }, // Parameter defaults
    new { name = @"\D+", id = @"\d+" } // Types
);

I'm building nodes in code with DynamicNode

I'm not setting Action, or rather, sets Action=null

I'll then add "Name" & "Id" as RouteValues.

When I run I'll get:

The node with key 'KEY' and title 'TITLE' has both an empty 'action' and empty 'url', which is not allowed

This worked in v3.

What changed?

1

1 Answers

1
votes

The only thing that has changed in this case was to add validation to the SiteMap to ensure that a node falls into one of the valid node prototypes:

  • A routing-based node
  • A URL-based node
  • A non-clickable grouping node
  • A dynamic node provider definition node

The validation was added because a lot of people were setting conflicting properties and then couldn't figure out how to get a working configuration. So now instead of having to ask a question, they can see a detailed error message that tells them what is wrong so they can fix it.

In hindsight, it probably would have been better to make the check on the controller property instead of action, but at the time I assumed there would be an issue with that because controller is optional in XML configuration (it will inherit the controller from its parent node).

So, in short, you are getting this error because your action property is null or empty string. To make it match your route, you will need to set your action explicitly to "Index".

That said, if you are not satisfied with this solution, you could open a new issue on GitHub or send a pull request with a proposed fix.