1

I have a problem configuring multiple hostnames in Composite C1.

Background:
I have two websites in C1: site1 and site2. The C1 installation is mainly for site1 and works with the host www.site1.com (and alias site1.com).
Now I've added another site, site2, to C1. When browsing to site1.com/site2 I end up on the site2 website. All fine.
Then I try to add another hostname, www.site2.com, to URL Configuration -> Hostnames. After adding www.site2.com and browsing to www.site2.com I get the following exception: "Item has already been added. Key in dictionary: '' Key being added: ''"

The stacktrace looks as follows:

[ArgumentException: Item has already been added. Key in dictionary: '' Key being added: ''] System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) +9353115 System.Collections.Hashtable.Add(Object key, Object value) +11 Composite.Core.Collections.Generic.Hashtable`2.Add(TKey key, TValue value) +105 Composite.Plugins.Routing.Pages.PageUrlBuilder.BuildUrlSet(IPage page, Guid parentPageId) +1935 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.BuildFolderPaths(SitemapBuildingData pagesData, IEnumerable`1 elements, IDictionary`2 urlToIdLookup, IPageUrlBuilder builder) +253 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.BuildMap(UrlSpace urlSpace) +2200 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.GetMap(PublicationScope publicationScope, CultureInfo localizationScope, UrlSpace urlSpace) +482 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.GetPageUrlBuilder(PublicationScope publicationScope, CultureInfo localizationScope, UrlSpace urlSpace) +9 Composite.Plugins.Routing.Pages.DefaultPageUrlProvider.ParseUrl(String relativeUrl, UrlSpace urlSpace, UrlKind& urlKind) +311 Composite.Plugins.Routing.Pages.DefaultPageUrlProvider.ParseUrl(String absoluteUrl, UrlKind& urlKind) +306 Composite.Core.Routing.Pages.C1PageRoute.GetRouteData(HttpContextBase context) +156 System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +287 System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60 System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +86 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Does anyone have a solution for this?

Thanks in advance...

UPDATE:
After changing the dll suggested by Dmitry Dzygin I get the following stack trace:

[ArgumentException: Item has already been added. Key in dictionary: '' Key being added: ''] System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) +9353115 System.Collections.Hashtable.Add(Object key, Object value) +11 Composite.Core.Collections.Generic.Hashtable`2.Add(TKey key, TValue value) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Core\Collections\Generic\Hashtable.cs:28 Composite.Plugins.Routing.Pages.PageUrlBuilder.BuildUrlSet(IPage page, Guid parentPageId) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Plugins\Routing\Pages\PageUrlBuilder.cs:190 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.BuildFolderPaths(SitemapBuildingData pagesData, IEnumerable`1 elements, IDictionary`2 urlToIdLookup, IPageUrlBuilder builder) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Core\WebClient\Renderings\Page\PageStructureInfo.cs:630 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.BuildFolderPaths(SitemapBuildingData pagesData, IEnumerable`1 roots, IPageUrlBuilder pageUrlBuilder, IDictionary`2 urlToIdLookup) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Core\WebClient\Renderings\Page\PageStructureInfo.cs:612 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.BuildMap(UrlSpace urlSpace) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Core\WebClient\Renderings\Page\PageStructureInfo.cs:559 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.GetMap(PublicationScope publicationScope, CultureInfo localizationScope, UrlSpace urlSpace) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Core\WebClient\Renderings\Page\PageStructureInfo.cs:277 Composite.Core.WebClient.Renderings.Page.PageStructureInfo.GetPageUrlBuilder(PublicationScope publicationScope, CultureInfo localizationScope, UrlSpace urlSpace) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Core\WebClient\Renderings\Page\PageStructureInfo.cs:342 Composite.Plugins.Routing.Pages.DefaultPageUrlProvider.ParseUrl(String relativeUrl, UrlSpace urlSpace, UrlKind& urlKind) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Plugins\Routing\Pages\DefaultPageUrlProvider.cs:249 Composite.Plugins.Routing.Pages.DefaultPageUrlProvider.ParseUrl(String absoluteUrl, UrlKind& urlKind) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Plugins\Routing\Pages\DefaultPageUrlProvider.cs:206 Composite.Core.Routing.Pages.C1PageRoute.GetRouteData(HttpContextBase context) in c:\Builds\1\Freja\CodeplexBuild\Sources\Public\Composite\Core\Routing\Pages\C1PageRoute.cs:90 System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +287 System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60 System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +86 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Tech
  • 651
  • 1
  • 8
  • 14

1 Answers1

2

Looks like some of kind of a url collision when 2 C1 pages received the same url or something like that. As a solution I recommend you to copy debug version Composite.dll file and Composite.pdf files to the /bin folder of your website. You can find those at Codeplex in "Other available downloads section" of the release page ( http://compositec1.codeplex.com/releases/view/80764 ) After that you will see the exact line in the code that caused it. Once you have it, I'll be able to either fix it or to add some code assertions/validation logic.

Update.

Looking through code it appears that the exception is possible only if you have 2 websites with empty "UrlTitle" field. Normally there's validation logic that prevents this situation from happenning. Try to edit both website's roots, give them not empty "Url Title" fields, and publish them afterwards, that should solve the issue. If the bug is still persists, I either need a better repro (I failed to reproduce it with the provided one), or if you send me a copy of a website, I'll debug it.

Dmitry Dzygin
  • 1,258
  • 13
  • 26
  • Thank you for your response. After changing the dlls i get the following Stack Trace: – Tech Mar 07 '12 at 10:30
  • it is missing, can you try to post it once again, or edit the original question – Dmitry Dzygin Mar 07 '12 at 10:46
  • or email me ddz at composite.net – Dmitry Dzygin Mar 07 '12 at 11:29
  • Sorry. It submited my comment before I could finish it :( I've edited the question to contain the new stack trace. I was not allowed to post that much text as a comment. – Tech Mar 07 '12 at 11:46
  • hi @Tech, I updated the answer 8 March, there's a change you haven't received a notification. I made a fix, but I don't know which setup actually reproduced the problem. Please check the updated answer – Dmitry Dzygin Mar 12 '12 at 10:00
  • Thank you for your answer. I also thought that I hade two sites with empty UrlTitle, but I could only find one, which is quite weird. On the other hand, I would like to have an empty UrlTitle on two site since I want to be able to address both site1.com and site2.com Anyhow. Finally I found that the published version of the demo site still had an empty UrlTitle. After publishing the page it works fine. Thanks a lot for all your help! – Tech Mar 15 '12 at 05:06
  • @Tech if you add 2 hostname bindings "site1.com" and "site2.com", you will have short urls for both of the sites. UrlTitle is used for root pages only when there's no related hostname binding or request is coming from an unregistered hostname – Dmitry Dzygin Mar 15 '12 at 08:38