Using .config Specific to a Site for Multiple Sites – Single Installation Options
psterling@homax
Posted: Tuesday, January 29, 2008 7:32:38 AM

Rank: Fanatic

Joined: 10/30/2007
Posts: 215
Location: Bellingham
Does anyone have an idea on how I may go about specifying a configuration value defined in a .config file that is unique to each site in a multi-site Umbraco installation?
For example:

For each site I wish to use a unique account to access a 3rd-party web service. This account is defined in web.config. So, for one site the value is:

<add key=”superWSAccount” value=”uid=Mickey;pwd=Mouse” />

And for another site the value is:

<add key=”superWSAccount” value=”uid=Donald;pwd=Duck” />

And so on….

I could always create a configuration class (or an elegant XSLT macro) that would take into account the current site instance and do some parsing to come up with the specific value to retrieve from .config:

<add key=”SiteOnesuperWSAccount” value=”uid=Mickey;pwd=Mouse” />
<add key=”SiteTwosuperWSAccount” value=”uid=Donald;pwd=Duck” />


But this is getting awfully dependent on lots of string values and settings and oh my….
If you have a completely different approach to this I’d welcome that as well.

Thanks,
-Paul


motusconnect.com :: level-2 certified :: MVP 2008/2009
psterling@homax
Posted: Friday, February 01, 2008 2:19:31 PM

Rank: Fanatic

Joined: 10/30/2007
Posts: 215
Location: Bellingham
I'm not sure if this has always been painfully obvious or if I'm just being thick, but here's my solution to site specific config values (yes, I know it's simple):

Using Document Type Properties I simply created the required properties on a relevant node - the Checkout page in this case - and used

umbraco.presentation.nodeFactory.Node.GetProperty()

to retrieve the values.

Feel free to let me know if I'm missing something here.

-Paul


motusconnect.com :: level-2 certified :: MVP 2008/2009
jHodgkinson
Posted: Friday, February 01, 2008 2:37:14 PM
Rank: Fanatic

Joined: 3/15/2007
Posts: 378
Location: Cary, NC USA
could you remove this from the .config and put it in a business component method and then call as needed:

Code:


public string getConnectionString()
{
     //get server environment
     string strServer = Convert.ToString(HttpContext.current.Request.ServerVariables["SERVER_NAME"]);

     //get connection string        
     switch(strServer) {
          case "site1.domain.com":
               return "conn string #1 info";
          case "site2.domain.com":
               return "conn string #2 info";
          case "site3.domain.com":
               return "conn string #3 info";
          case "site4.domain.com":
               return "conn string #4 info";
          case "site5.domain.com":
               return "conn string #5 info";
          default:
               return "default conn string info";
     }
}



jHodgkinson
Posted: Friday, February 01, 2008 2:40:28 PM
Rank: Fanatic

Joined: 3/15/2007
Posts: 378
Location: Cary, NC USA
Paul - must have missed this when reading over... never mind me... need to go drink a pot of coffee and wake up...

Quote:


I could always create a configuration class (or an elegant XSLT macro) that would take into account the current site instance and do some parsing to come up with the specific value to retrieve from .config:


psterling@homax
Posted: Friday, February 01, 2008 2:43:39 PM

Rank: Fanatic

Joined: 10/30/2007
Posts: 215
Location: Bellingham
John -

No worries...I missed something even more obvious else I wouldn't have posted this in the first place.

-Paul

motusconnect.com :: level-2 certified :: MVP 2008/2009
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.