Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Multiple nodes with the same URL" after updating to v4.5 #280

Closed
AlonCG opened this issue Feb 13, 2014 · 4 comments
Closed

"Multiple nodes with the same URL" after updating to v4.5 #280

AlonCG opened this issue Feb 13, 2014 · 4 comments

Comments

@AlonCG
Copy link

AlonCG commented Feb 13, 2014

First, thanks for continuing to support this project.

I have an MVC5 project where I use MvcSiteMapNodeAttribute[s] to set up my SiteMap. I thought it would be easier than maintaining an XML file. I am also using Ninject for my DI container. I followed these two posts to set up my attributes:
https://github.com/maartenba/MvcSiteMapProvider/wiki/Defining-sitemap-nodes-using-.NET-attributes
and post #197 to not use the XML file at all ...

My node attributes had been working properly until today's upgrade to 4.5... and I could not see from the release notes (just a quick/cursory read) that would let me know what to do. Similar to issue #230 ... my duplicate nodes issue is coming from GET/POST action pairs. Example:

[MvcSiteMapNode(Title = "Clone Rule", ParentKey = "AccessRules", Key = "CloneRule", HttpMethod = "GET")]
public virtual ActionResult Clone(Guid id) ...

and

[HttpPost, MvcSiteMapNode(Title = "Clone Rule", ParentKey = "AccessRules", Key = "CloneRulePost", HttpMethod = "*")]
public virtual ActionResult Clone(AccessRule model) ...

I've tried various combinations of the "Key" and "HttpMethod" properties, and they all lead to the same error. Obviously I missed something in the release notes ... can you just get me pointed in the right direction?

@NightOwl888
Copy link
Collaborator

What is the error message you are getting?

The logic for the one that shows the "duplicate nodes" in detail has not changed, however the check for duplicate URLs had to be done differently to fix the "disappearing breadcrumb" issue. Offhand, I can't think of how it could arrive at a different result than it was previously, but it is possible. Actually, I am not sure how this configuration could have passed that check before.

Could you build a small demo project and post it on GitHub or zip it and make it available for download so I can have a look?

@AlonCG
Copy link
Author

AlonCG commented Feb 13, 2014

I received the error:
Multiple nodes with the same URL '{0}' were found. SiteMap requires that sitemap nodes have unique URLs.

Insert every GET/POST action pair into the {0} placeholder that I have in my application. I sent you an example for one that was erroring ... the initial configuration was ...

[MvcSiteMapNode(Title = "Clone Rule", ParentKey = "AccessRules", Key = "CloneRule")]
public virtual ActionResult Clone(Guid id) ...

and

[HttpPost, MvcSiteMapNode(Title = "Clone Rule", ParentKey = "AccessRules", Key = "CloneRule"]
public virtual ActionResult Clone(AccessRule model) ...

Which worked up until this morning when I upgraded to v4.5. So I tried numerous other combinations of the attribrute properties to try and get it resolved ... with no such luck. Can you just tell me how it should have been defined initally, since it should not work they way I did it?

I will try to get you a sample app over the next few days, my weekend over here started an hour ago and I need to get home!

Thanks!

@NightOwl888
Copy link
Collaborator

I didn't say it shouldn't, I said I couldn't see why it would have :). The configuration you have looks like it should be fine.

Honestly, I didn't think there would be any issue with keeping this check - the only real difference was that the case sensitivity of the URL was changed so it is now case insensitive to be consistent with Microsoft's model. But there is no real reason I can think of to keep the MVC configured nodes in this check, since there are exceptions such as this to what makes a "unique" node that can't be identified by URL alone, so the unique URL check for these nodes has been removed.

However, this is one of the issues to fix in v5 because there really should be some way to enforce the fact that MVC routing nodes must be unique and not generate any of the URLs that were configured explicitly. Otherwise people could configure multiple nodes with the same signature and then wonder why only the first one registered ever matches the URL.

@AlonCG
Copy link
Author

AlonCG commented Feb 16, 2014

Thanks ... I just made sure my Keys were in-fact unique, as they probably should have been by adding "..Post" to the proper actions. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants