Running multiple websites under N2 CMS

RTFM indeed!

Don’t get me wrong, I really like N2 CMS, but the documentation blows chunks. The number of typos and spelling mistakes in both the online documentation and in the source-code comments is high, but some of the advice given is just plain wrong or out-of-date (which is almost worse than no documentation.. unless you are desperate for ideas). Time for somebody to write a book on N2 CMS… any takers?

The path to enlightenment has many turns

Basically don’t rely on one source of infomation for N2 CMS, use anything/everything you can find. Believe nothing, but try everything! For instance, when attempting to setup multiple website under a single N2 installation I read the single Advanced topic on the N2 site, followed by at least a dozen forum posts:

  • The Advanced topic page incorrectly says to change a “hosts” setting in the web.config, but it is called “host”. Little details like trip up newbie coders all the time.
  • The responses to some posts don’t actually seem to be answering the question asked. Some actually give code examples that are just plain wrong or at least misleading.
  • Multiple N2 websites does require correct setting up of IIS to have multiple domains/subdomains all pointing at the same IIS application.
  • Multiple N2 websites do not work under the Visual Studio debugging webserver. Any domains, aside from the default, are ignored.

How we got it working

  1. Added ISitesSource interface to our HomePage class(es). HomePage is our N2 content class (derived from ContentItem) and used for all our site home pages. You may have different ones per site instead.
  2. Implement a property called Host with an [EditableTextBox] property on any/all home page classes.
  3. Implement a GetSites method that yields an N2.Web.Site(Parent.ID, ID, Host) value on any home page classes. The Host value comes from the previous property we added in step 2. The ID is from the current node and the Parent.ID is the id of the root node that owns the start pages.
  4. Install a local copy of IIS for testing. This is needed as the Visual Studio debug website engine does not support host names (which is required for this feature to work). It means you will have the extra step of publishing your website under IIS to test multi-site functionality. To test one site at a time in Dev Studio just change the initial startPageId in the host setting in web.config.
  5. Add aliases to the hosts file to point any/all test domains at localhost (
  6. Publish and install your N2 CMS web site under IIS for your main site, e.g. under a domain called
  7. Ensure that site is running and you can get to the admin interface via /edit
  8. Add additional test sites e.g., but point the physical path of each site at the previous installation directory of the website. This ensures they all run the same web application, saving memory and sharing code/data.
  9. Run up the admin install, e.g. on
  10. Do a normal install, but make sure you add separate root and start nodes for your new site. This is critical as the root must be above all the new sites and each site will have its own start node.
  11. From within the admin interface add extra start nodes to the root node (one for each website you want) and set the Host property of each to its matching domain name (e.g.,
  12. Also put some differing values in the content property of each start node (so you can tell the different sites are working).
  13. Note the ID numbers of each start page, as these have to be listed in the web.config.
  14. Edit the host > sites settings in web.config, adding an entry per hostname/domain. These entries specify which hostnames point to which start nodes when they start.
  15. Now try your various domain/subdomain names under IE (chrome appears to ignore hosts file entries!). If it is working you will see your different start pages under each website.
  16. Give a sigh of relief.

I will pad this out with screen shots and code examples when I get a chance, but thought I should get down the details before I forget :)

Cheers, Dave

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.

WordPress Themes