Is there a setting to allow multiple nodes with the same URL? We've setup a small CMS type system where web content admins can add new pages with content and widgets to the website. They sometimes make the mistake of adding the same name to multiple pages under the same parent causing 2 nodes to have the same URL. I would rather not showing and ignoring the duplicate than throwing an exception.
Asked
Active
Viewed 82 times
1 Answers
0
The URL (when supplied) is used as a key of a dictionary. By definition, the key of a dictionary must be unique. Even if the duplicate URL check were removed, the dictionary would throw a more cryptic duplicate key exception.
I would suggest sanitizing the data before reading it with IDynamicNodeProvider
or ISiteMapNodeProvider
.
Options
- Add a check to the data entry form to ensure the URL is unique before allowing it to be saved.
- Put a unique constraint on the URL field in your database to throw an exception upon data entry instead of when it is read.
- Put a distinct filter in your query so only one of the duplicate URL records is considered when adding them to the
SiteMap
. - Consider using
controller
,action
, andid
(from the primary key) when using data-driven URLs. The only thing that really needs to be data-driven are the Routes, and the URLs will be resolved correctly withinMvcSiteMapProvider
.

Community
- 1
- 1

NightOwl888
- 55,572
- 24
- 139
- 212
-
I've for now added my own setting ErrorOnSameUrl that if set to false, will check the dictionary for a duplicate key (ContainsKey), if found, it won't add to the dictionary and get the next record. I'm 100% certain that I don't have any multiple urls but I still get the error saying multiple urls exist. The url the error tells me is a duplicate is not a duplicate. Recycling the app pool fixes it. I'm guessing theres something going on with the caching? Until I find what the issue is, this is working for now. – garethb Mar 29 '16 at 23:17