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

Forums / Set-up & Installation / Multiple websites and one central database?

Multiple websites and one central database?

14 posts, 0 answered
  1. Eric Smith
    Eric Smith avatar
    1 posts
    Registered:
    11 Nov 2004
    08 Feb 2008
    Link to this post
    Is it possible to have multiple websites run on one database.  For example, www.mydomain.com and www.yourdomain.com would use ourdatabase.mdf.   

    Thanks,

    Eric
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Feb 2008
    Link to this post
    Hello Eric Smith,

    You can use a single database for multiple sites. Each data provider has a property applicationName. By this name the data is separated or shared between sites. By default this name is “/”. So if you have two sites connected to the same database and both sites are set so their CMS data providers are with identical application names, both sites will act as one. That is, pages added to one of the sites will appear on the other as well. On the other hand, if you set them with different names, they will act as if they were connected to different databases.

    In other words, if you set all sites to use a single database with the same application name, your editors will have to dig through to find their information. Setting the sites with different application names will solve the problem with the editors but when mirrored to the production server, the sites will continue to act as separate ones. Actually, on the production server only the entries for the default provider will be visible. To overcome this problem, you have two choices:

    1.    Use a single database and different application names. When the new records are copied to the production database, make all application names the same (this could be done using a stored procedure). To achieve this, follow the steps below:

    1.1. Create all projects that are going to be merged at the end.
    1.2. Specify the connection strings so that all projects are connected to the same database.
    1.3. Set an appropriate applicationName for each project (e.g. department site) in the web.config like this:

    <cms defaultProvider="Sitefinity" pageExtension=".aspx">    
    <providers>
    <clear/>
    <add name="Sitefinity"
    applicationName="/Department-1"
    allowPageHistory="true"
    allowPageWorkflow="false"
    type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data"          connectionStringName="DefaultConnection" />
    </providers>
    </cms>

    You need to do the same for <cmsEngine> section (Generic Content providers) if you are going to use shared content or other modules deriving from Generic Content (News, Blogs).

    2.    Use separate databases for each site on the development side. Set all sites to use the same application name or leave the default settings. Merge all databases on the production server.

    You can also find this information anytime in the Sitefinity User Manual, section "Working with multiple Web Sites".

    Do let us know if you have any other inquiries.

    Best Regards,

    Georgi
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  3. ColdCold
    ColdCold avatar
    6 posts
    Registered:
    26 Jul 2007
    27 Sep 2009
    Link to this post
    Hello,

    I know this is an old post, but I don't see a section entitled "Working with multiple Web Sites" in the current User Manual.

    I'm using Sitefinity 3.7.Community edition.  I would like to use a single database to setup a few independent Sitefinity web sites (no shared content or templates required).  Can this be done?

    As suggested in the post, I tried creating a new project then before completing the Project Startup wizard (before entering database info) I edited the web.config file to use a specific applicationName.  I repeated the process with a second site, but I couldn't import sample content and a new page from the first site appeared in the second site, so clearly this wasn't working.

    Is there a way I can do this?

    Thank you!
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 Sep 2009
    Link to this post
    Hi ColdCold,

    Please take a look at the following forum post which describes how to configure shared and  not shared content.

    Below is the configuration that you should have if  you want to use one database for several websites and hide all pages between these websites.

    first website

     <providers> 
            <clear /> 
            <add connectionStringName="DefaultConnection" allowPageHistory="true" 
              allowPageWorkflow="false" name="Sitefinity" type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data" applicationName="/websiteone" /> 
     </providers> 

    second website

    <providers>  
            <clear />  
            <add connectionStringName="DefaultConnection" allowPageHistory="true"  
              allowPageWorkflow="false" name="Sitefinity" type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data" applicationName="/websitetwo" />  
     </providers>  

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. ColdCold
    ColdCold avatar
    6 posts
    Registered:
    26 Jul 2007
    28 Sep 2009
    Link to this post
    Thanks Ivan,

    Do I only need to add applicationName in that one place, or should I change the applicationName on ALL of the Sitefinity providers in web.config?

    thank you.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Sep 2009
    Link to this post
    Hello ColdCold,

    If you do not want to share any content you should have different applicationName for the providers in your applications. When the application name is the same and your project uses one database the content will be shared.

    I hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. ColdCold
    ColdCold avatar
    6 posts
    Registered:
    26 Jul 2007
    30 Sep 2009
    Link to this post
    Hi, thanks for your help, but I'm still having trouble with this.

    I created a new project then before completing the Project Startup wizard (before entering database info) I edited the web.config file to use a specific applicationName.  I replaced all occurences of applicationName="/" with applicationName="/website1" and all occurences such as applicationName="/Blogs" with applicationName="/website1/Blogs" throughout web.config.  Then I added applicationName="/website1" to the section you showed in your post, like this:

    <add connectionStringName="DefaultConnection" allowPageHistory="true"  
              allowPageWorkflow="false" name="Sitefinity" type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data" applicationName="/website1" />

    I finished creating the site and created a new page in the site.  Everything seemed fine.
     

    Next, I repeated the process with a second site, this time using "website2" in every location and I used the same Theme template as the first site.  When I got to the last step in the Project Startup wizard, I tried to import the sample content but I got the following error:

     

    Importing template data failed: Violation of PRIMARY KEY constraint 'PK_sf_CmsControlProperty'. Cannot insert duplicate key in object 'dbo.sf_CmsControlProperty'. The statement has been terminated.. Check the error log for more details.

    All I could do at this point was to uncheck the box "Use this template with sample content" and then I completed the wizard.  It created an empty site, with no sample content, no theme, just a blank empty site.

    How can I use a single database to create a new, independent site using the same theme template and sample content, but separate in the sense of no shared content?

    thanks again.

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Sep 2009
    Link to this post
    Hello ColdCold,

    1. Make sure that both the projects are the same version - otherwise you are making upgrade, downgrade.

    2. Please take a look at the following post which describes similar problem. It seems that you are trying to import the same data twice.


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. ColdCold
    ColdCold avatar
    6 posts
    Registered:
    26 Jul 2007
    04 Oct 2009
    Link to this post
    Hello again, ok it seems we are making some progress.  Based on your 2nd suggestion, I have followed the instructions in that other blog post.  I changed the GUIDs in CmsPages.xml using the code you provided and then I gave the GenericContent provider a new applicationName.  Now it seems it almost worked.  But this time, while creating the second website, as I tried to import the sample data, I got a new error:

    Importing template data failed: An object with the same primary key already exists in the cache.. Check the error log for more details.

    I'm not sure where to find this error log.  Can I clear this cache by simply restarting the web server perhaps?

    thanks.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Oct 2009
    Link to this post
    Hello ColdCold,

    The error log is located under App_Data folder of your project. Most probably any data to the xml files was not correctly replaced. You could try restarting the application to clear the cache. Let us know how it goes. If the problem persists you can send the stack trace from the log file.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. ColdCold
    ColdCold avatar
    6 posts
    Registered:
    26 Jul 2007
    06 Oct 2009
    Link to this post
    Hi Ivan,
    This is the stack trace from sitefinity.log.

    Exception Type: Nolics.ORMapper.Base.NolnetException

    Message: An object with the same primary key already exists in the cache.

    Source: Nolics.Engine.v4.2

    Stack Trace:
       at Nolics.ORMapper.Base.OdbClassHelper.CreateClass(IOdbClass cl, Transaction tran, OdbDataProvider provider, ObDataCache cache, OdbObjectStates& state, OdbDataProvider& curProvider, ObDataCache& curCache)
       at Telerik.Cms.Engine.Data.MetaData.Create(Transaction tran, OdbDataProvider provider, ObDataCache cache)
       at Nolics.ORMapper.Base.Transaction.Create(IOdbClass mem, OdbDataProvider provider)
       at Telerik.Cms.Engine.Data.ContentVersion.SetMetaDataInternal(Transaction tran, IMetaInfo metaInfo, Object value)
       at Telerik.Cms.Engine.Data.ContentVersion.SetMetaData(String key, Object value)
       at Telerik.Cms.Engine.Data.CmsContentBase.SetMetaData(String key, Object value)
       at Telerik.Cms.Engine.ContentProviderBase.Import(DataSet dataSet)
       at Telerik.Cms.Engine.GenericContentModule.Import(DataSet source)
       at Telerik.Cms.Tools.SiteExporter.Import(String templateName)
       at Telerik.Cms.Web.StartupWizard.SiteTemplatePane.DoWork()
    ------------------------------------------------------------------------------------


    Is this error consistent with the GUIDs not being correctly replaced in CmsPages.xml?  I used the code you provided in order to replace the GUIDs.

    Is there a way to add the sample content to the site without having to use the Project Startup wizard to create another new site?

    thanks.
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 Oct 2009
    Link to this post
    Hello ColdCold,

    The error seems to be thrown form Generic Content - SetMetaData methods. If you take a look at the stack trace you will see that SetMetaData and MetaData classes are called. The provided code in the forum posts works only for pages. It is not possible to create similar code for content items because the architecture there is different and more complex. By design there is a limitation regarding the importer. It is developed to import data in an empty database.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  13. Trevor
    Trevor avatar
    1 posts
    Registered:
    15 May 2008
    08 Jul 2010
    Link to this post

    I know this thread is old, however it seemed the most relevant place for this question. Using the applicationName attribute works as expected and separates content between 'sites' with different values for applicationName. For some modules, however -- notably Polls -- I cannot figure out how to separate content between sites. The Polls module doesn't seem to be based on generic content, it has no entry under cmsEngine/providers, and while modifying the "polls" configuration directly under "telerik" doesn't cause a configuration error, it has no effect (all Polls are still visible on all sites).

    <polls defaultProvider="NolicsPollsProvider">
      <providers>
        <clear/>
        <add name="NolicsPollsProvider" connectionStringName="DefaultConnection" type="Telerik.Polls.Data.NolicsPollsProvider, Telerik.Polls.Data" applicationName="/MySite1" />
      </providers>
    </polls>

    I tested this using the most recent SP of Sitefinity 3.7. Any help here is greatly appreciated.

    Kind regards,
    Dusty
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Jul 2010
    Link to this post
    Hi Dusty Kline,

    There is no relation IPollItem - Application and it is not possible to separate the polls based on provider name. This is how the module data layer has been created.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
14 posts, 0 answered