Monday, May 18, 2015

Importance of Case-sensitivity of hostName attribute of Sites config node

Today, we faced a strange issue, which questioned my knowledge of Site Definition configurations in Sitecore :-D

One of my colleague had a Sitecore instance with site definition had hostnames defined.

Ex:

<site name="website" hostname="abc.xxx.local" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="extranet" ... />


But, he had his IIS site defined with "xxx.local".

Even though hostname attribute is "abc.xxx.local", request to "xxx.local" works fine and match to the "website" site definition.

This made me confused as my knowledge said only request that should map to "website" site defition is request with same value as hostname attribute value.

I had a quick google search and found my thinking was correct.
https://sdn.sitecore.net/SDN5/Articles/Administration/Configuring%20Multiple%20Sites/Configuring%20Sites%20in%20web,-d-,config%20File.aspx

So, when Sitecore it self saying this, how is this not working accordingly is my next question.

Then, I found Jon West's following blog post about hostName setting, which explained the real issue with our setting.
https://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2013/08/mapping-hostnames-to-sites-with-the-sitecore-aspnet-cms.aspx

Quote :
As a word of caution, in several cases I have seen where device resolution did not work as a developer expected, the issue was that their configuration used hostname (with a lowercase n in the attribute name) rather than hostName (with an uppercase N). Be sure to capitalize the N.

 After changing "hostname" to "hostName", everything started to work accordingly. :-)

No comments:

Post a Comment