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

Forums / Deployment / Change Sitefinity instances based on user selection

Change Sitefinity instances based on user selection

4 posts, 0 answered
  1. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    13 Jun 2010
    Link to this post
    Ivan,

    I am working on a Generic Content deployment process where I'm storing all of my content in an Excel spreadsheet, and then importing the data into Sitefinity from that spreadsheet. Each time I run it I simply erase all generic content in a chosen category, and re-import from the spreadsheet. It works very well in our Development environment, and equally well if I change the connection string in the web.config to point to QA or production.

    However, what I'd like to do is have a radio option or drop-down to specify which instance to deploy (DEV, QA, UAT, PROD) so that we can give this tool to one of our marketing folks and have them manage the spreadsheet and deployments. I don't want to rely on them changing the web.config.

    Is there a way to change the Sitefinity connection based on a user selection? I see that there's an overload for the constructor of 'ContentManager', but that doesn't seem to be what I need. It looks like that is for choosing which 'type' of content (News, Blogs, etc.) that we want to retrieve.

    This is not a high priority issue, but it would be nice to get this set up so that it's out of my hands.

    Thank you,

    Scott McNeany
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    14 Jun 2010
    Link to this post
    Hi Scott McNeany,

    Thank you for contacting us. 

    The changing of the connection string at a runtime would not be possible - every change to web.config restarts the application and you might loose some data, if it is not persisted anywhere. 

    I am wondering if the multiple provider approach could be used in this scenario though. Let me elaborate - each provider is related with a connection string. So, you can define more than one connection string, and more than one providers for the Generic Content. Each provider will work with different database - QA/Stage/Dev/Live, so it will use different connection string. Then the Content Manager class could be initialized with different provider - the News, Blogs etc, are just different providers of the same architecture - Generic Content. That's why we call these modules Generic Content based. 

    You may take a look at the user manual and check how additional providers could be added, or simply open the web.config file and check how each module uses the Default Connection string (Sitefinity), defined in the connection strings collection. 

    I hope this helps. 

    Best wishes,
    Georgi
    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.
  3. debett
    debett avatar
    16 posts
    Registered:
    12 Feb 2007
    02 Sep 2010
    Link to this post
    Hi Georgi,

    I was wondering if you could recommend a solution for me.

    I have a similar scenario. So, for all of my calls to the database I specify the connection I want, while I have thousands of connections in web.config.

    Is there any way to specify which connection I want to use for sitefinity? In asp.net I usually have a class with a property connection string, so no matter what I do - use sql data source (which I don't use), object data sources, etc, I pass this property and the property knows which connection to pass. I know (I hope) how to achieve it in membership and role providers, I implemented pretty much the same logic as in asp.net code. Here you are suggesting

    "I am wondering if the multiple provider approach could be used in this scenario though. " - what kind of "multiple provider approach" you are referring to? For instance, even though I am authenticating, getting roles from the correct connection string, when I go to, let's say create new page - it creates it in the default database. . . I hope you will be able to understand me:)

    Thank you.
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    06 Sep 2010
    Link to this post
    Hi debett,

    A description of the provider approach can be found here. For each type of content the CMS uses providers. For the pages the providers are listed in the telerik/cms/providers configuration section:
    <cms defaultProvider="Sitefinity" pageExtension=".aspx" siteTemplate="" additionalExtensions=".html" projectName="Sitefinity37SP3" disabled="false" pageEditorUIMode="Overlay">
        <providers>
            <clear/>
            <add connectionStringName="DefaultConnection" allowPageHistory="true" allowPageWorkflow="false" cachingProviderName="ASPNET" name="Sitefinity" type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data"/>
        </providers>

    You can create a custom pages provider which inherits from the default one. Then override the property ConnectionStringName. This property sets the connection string to the database. We pull the connections from the dataAccess configuration section:
    <dataAccess defaultConnection="DefaultConnection">
        <connections>
            <add name="DefaultConnection" driver="Telerik.DataAccess.Providers.ExtendedSqlServer2005Provider, Telerik.DataAccess" connectionStringName="Sitefinity"/>
            <add name="GenericContentConnection" driver="Telerik.Cms.Engine.Data.Providers.GCSql2005Provider, Telerik.Cms.Engine.Data" connectionStringName="Sitefinity"/>
        </connections>
    </dataAccess>

    The data access provider make the connection to a database connection string listed in <connectionStrings> section using the proper database driver depending on your db type. So for each different db you have to add a connection in data access configuration section and your custom provider for pages you will set the connection to the proper db.

    Kind regards,
    Radoslav Georgiev
    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
4 posts, 0 answered