vendredi 2 janvier 2015

Best way to handle shared configuration settings between Web Parts?



Let's say I have several web parts as part of a solution, all of which need to look up certain information in some list. Within the code, they need to know the name of the list to use TryGetList (or equivalent for GetList or whatever). And if the list name changes, or a completely new list needs to be used, the web parts need to be told to change were they are looking. The options as I see them:


1. In the code as constants (defined in one place)


Pros:


Presumably the best performance


Single place to update


Cons:


Updating requires changing the code and redeploying the solution


2. As a property in SharePoint’s web.config


Pros:


Single place to update


Update can be done on a web app without redeploying the solution


Cons:


Requires Powershell to perform the update


3. As properties of the Visual Web Part


Pros:


Updates can be done through SharePoint’s UI via Edit Page


Cons:


Update would need be done separately for each web part


4. As a new list


Pros:


Updates can be done using the usual list interface


Cons:


Presumably the worst performance as it adds an additional query to the config list


Having to redeploy or remember multiple places that need to be updated both seem like big enough issues that 1 and 3 are just bad options. Are the performance differences between 2 and 4 significant, either in terms of X seconds longer every time the page loads, or in terms of if the web part runs Y times causing Y queries to the config list, once Y is large enough it might slow down the whole server? Am I missing anything about these options or missing options?








0 commentaires:

Enregistrer un commentaire