Skip to content
April 4, 2015 / kiranpatils

Sitecore Multisite Basics

Challenge:

In a small city, there used to be a company. Where two guys used to work. Mr. Enthu (a.k.a. Mr.E) and Mr. Basic (a.k.a. Mr.B). As name suggests Mr.E was always enthusiastic about anything. Whenever he used to see something new, He used to go to his friend. Mr. Basic. Again as name suggests Mr. B was always clear with his basics. And when anyone used to come to his with questions. He was explaining that person with all the basic information he had!

2015-03-31 00_07_54-Sitecore Multisite Basics by klpatil _ stripcreatorOne fine morning, Mr. E came to Mr. B and asked a question “How Sitecore resolves Multiple websites?”, and as per tradition Mr. B explained Mr.B in detail about Sitecore Multisite resolution process and this post shares those details with you!

Disclaimer — All characters in this publication are entirely fictitious and any resemblance to real persons, living or dead, is purely coincidental.

This question is special to me. Because, When I was learning Sitecore before 5-6 years back. And I asked same question to someone. And he denied to help me understand how it works? And then the journey began! I not only found out, How Sitecore Multisite works. But during this journey, I explored Sitecore a lot, and till today it never stopped! So, good to remember :

I am thankful to all those who saidno” to me. because of them, i did it myself. by Albert Einstein

Solution:

Sitecore-Multisite-v1 Before, we go and share Mr.B’s details. Let’s understand more about question. Most of the time. You will have multiple websites in your Sitecore. Most of us know how to make this work. i.e. Add Bindings, Add entries in SiteDefinition.Config etc. And If you search on web, you will find following nice articles to get you started with Sitecore Multisite:

  1. https://sdn.sitecore.net/Articles/Administration/Configuring%20Multiple%20Sites.aspx
  2. http://labs.steveottenad.com/run-multiple-sitecore-sites-from-one-installation/
  3. http://learnsitecore.cmsuniverse.net/en/Developers/Articles/2009/10/how-to-multisite-in-sitecore.aspx
  4. http://www.nonlinearcreations.com/Digital/how-we-think/articles/2014/11/Sitecore-host-name-attribute-in-multi-sites.aspx
  5. https://briancaos.wordpress.com/2010/03/01/working-with-multiple-sites-in-sitecore/
  6. http://firebreaksice.com/handling-multiple-hostnames-in-a-sitecore-multi-site-solution/

These all links are great place to start! But none of them covers “How it works?!”. As we are engineers we always ask “How do they do it?”. Because we know nothing is automatic in this world! Someone somewhere programmed to make it work! And to lay man it looks like it’s automatic!

Sorry being off track, let’s go back to Mr. E and Mr.B’s talk. Mr. B started drawing and he shared following drawing with Mr.E.

Multisite-v1

Mr.B said : My dear friend E, I would have been able to explain you by words. But as picture is worth a thousand words. I thought to diagram this for you. Let me help you to understand it.

It covers everything from a User requesting a host (www.X.com), till Sitecore resolves it and renders it. Please see the numbers on lines. Just follow them, and read following description. It will answer all your questions:

  1. Browser tries to resolve Web Server IP from Host-name (Good read :
    1. As shown in 1.a it tries to resolve it from Host file first (To be honest, I haven’t found any article. Whether it goes first to Host file or DNS — So, Happy to be corrected here!).  That’s why while working in local environment. When your Site is hosted in local and you would like that host-name to be resolved to your local box. You do entry in Hosts file
    2. Then it goes to DNS Server – 1.b Indicates that
  2. Now, Server has IP address of Web server. If it is in local (see 2.a) then it will be connected to local web server else it will go on remote web server (see 2.b).  Opens connection on Port 80 – Default Port of Web Server
  3. Now, we’ve reached to IIS. But on IIS there are multiple websites. e.g. X,Y,Z. Which website to use? And that’s where — IIS Bindings comes in to rescue. It checks requested host-name with bindings. And matched website gets control
  4. Now, Control goes to ASP.NET and then it comes to Sitecore:
    1. Site Resolution happens using Sitecore.Pipelines.HttpRequest.SiteResolver Processor. Located under <httpRequestBegin>
    2. Then it tries to resolve site using host name. By default Sitecore loads all Site information using Sitecore.Sites.ConfigSiteProvider which loads all the sites defined under <sites> node.
  5. That’s it!

Sounds good?! For simplicity I’ve removed lot of other things like Firewall, Load Balancer etc. And from Sitecore side before your page gets served lot of interesting thing happens in between. Like Item resolution, render Layout etc. May be sometime later. Will write on those topics. Or why don’t you write it? What you don’t have blog? Please create one. Read this Every developer should have blog!

Good To Read:

Thanks to Gliffy folks for proving Free Gliffy Chrome App!

Advertisements

6 Comments

Leave a Comment
  1. mawkstiles / Apr 6 2015 8:45 pm

    Three cheers to the one who explains the basics!

    • kiranpatils / Apr 11 2015 10:28 am

      Mark — I’ve shared your appreciation with Mr.B and He has said – Thanks for the nice words!

  2. VIMUKTHI SAJITH / May 25 2015 1:28 pm

    nice and very helpful tutorial.like a story: ) Thanks Kiran!!!!!!!

Trackbacks

  1. Technology trends you should know | A Place for C Sharpers/.Netters
  2. Multisites in Sitecore – A Collection of articles on web development by Nataraj Gandhi Arunachalam
  3. Sitecore Azure Basics | Sitecore basics!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: