1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to Create Multiple site in one sitefinity website?

How to Create Multiple site in one sitefinity website?

2 posts, 0 answered
  1. Pravat
    Pravat avatar
    59 posts
    Registered:
    22 Jun 2010
    31 Jan 2012
    Link to this post
    Hi,
    I am using Sitefinity 4.4 version. I have multiple sites that I need to build and I want to use one sitefinity website and different database for each site.
    Is there a way to dynamically change the DB connection on the fly?


    Thanks,
    Pravat Sharma.
  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    02 Feb 2012
    Link to this post
    Hi Pravat,

    At the moment multiple site management is not coming as out of the box feature, and changing the database used by the project with another one may cause errors, due to the fact that we store some sensitive information in the configuration files, which are related to a particular database ( ex. project name, role id's, etc. ). However you can create a single website and replicate the database few times and customize each one of the databases ( so there are practically 4 databases serving one site ). Such scenario is not tested but you can try to switch between the databases on the fly by getting the current connection string, editing it and setting the new one as a primary connection string. For example you can get a particular connection string by its name:

    var connString2 = Config.Get<DataConfig>().ConnectionStrings["Sitefinity"];
           string strConnString = connString2.ConnectionString;

    then you need to write some logic where you complete the process. I have googled few articles for you:

    http://codebetter.com/petervanooijen/2006/08/11/change-a-database-connection-string-from-code/

    http://www.codeproject.com/Articles/19578/How-to-persist-changes-to-My-Settings-ConnectionSt

    http://social.msdn.microsoft.com/forums/en-US/winforms/thread/e89b0402-12cf-4f24-8e7f-ec449aab75f6/


    Kind regards,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered