Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Enviorment Settings

  Asked By: Callie    Date: Jan 30    Category: Sharepoint    Views: 876

I have a question about updating environment settings in a web part,
the scenario is when I build a web part for test or dev some of the settings
i.e. connection string, web service url and other various settings change when I
build a production release and I don't want to store these values in the
sharepoint web.config due to the fact these web parts are deployed to a farm and
it becomes a maintenance nightmare, so I'm looking for some feedback on how
others have addressed this issue in the field.



6 Answers Found

Answer #1    Answered By: Michelle White     Answered On: Jan 30

Probably the easiest way is to include those settings  as custom
properties of the web  Part. Unfortunately, that would open them up to
anyone who has the ability to edit a web part. To prevent that you
could implement a custom edit panel for those properties and put
security in it, but that would take a fair amount of work.

Answer #2    Answered By: Sheena Ray     Answered On: Jan 30

The SharePoint framework provides for updating  web.config in a
multi-server farm  via the SPWebConfigModification object. Alternatively,
you could store  the information in the properties collection of an
appropriate object (SPFarm.Properties, SPWebApplication.Properties,

Answer #3    Answered By: Jaime Weaver     Answered On: Jan 30

Our approach is to manage this kind of configuration information as
properties of the associated Farm or WebApplication, using custom
administration pages and corresponding accessor classes.

Chris O'Brien's recently-released config  Store framework (
http://www.codeplex.com/SPConfigStore) addresses this in a very nice,
general-purpose way. I'd definitely give it a look.

Answer #4    Answered By: Anibal Baird     Answered On: Jan 30

Could you elaborate on your approach "manage this kind of
configuration information as properties of the associated Farm or
WebApplication, using custom administration pages and corresponding
accessor classes".

I would love to know how it is done. More detail would be greatly

Answer #5    Answered By: Karla Morrison     Answered On: Jan 30

For example, we have a web  part whose implementation needed database
connection information (which we didn't want to include as part  of the
WP properties, for security reasons). We defined a simple
DBConnectionStringManager class that's responsible for (and
encapsulates) storing and retrieving this information, specifically
using a property of the web application (serializing into an XML
string for simplicity)

SPWebApplication app = ...
app.Properties[ERP_DB_INFO] = dbInfo;

We then created a custom administration page (extending
that allows an administrator to edit the required info (provider,
connection string, user, pwd), using the DBConnectionStringManager
class to read and write the info. A custom action is used to add a
link to this page to the standard CAS application administration page.

The web part implementation also uses the DBConnectionStringManager
class to retrieve the connection  data at render time.

Hope this explains a bit more. I've simplified some details in the
telling -- for example, for one of our more complicated structures, we
actually defined a completely separate object in the SP config
database (using the SPPersistedObject), rather than using a farm  or
webapp property. But the basic approach is the same, just the
persistence implementation varies.

But, again, I'd definitely look at Chris O'Brien's config  Store
framework if I were doing it over again, certainly for the simple stuff.

Answer #6    Answered By: Patricia Richardson     Answered On: Jan 30

I appreciate your explanation and now I have the basic
idea on how to do this.

Didn't find what you were looking for? Find more on Enviorment Settings Or get search suggestion and latest updates.