Saving specific application configuration data to Sharepoint?

I am doing WebPart Sharepoint 2010 with the functionality of another main web application. To quickly develop Webpart, I imported the business logic assemblies used in the main web application. Webpart runs and extracts information about a specific application configuration from the web.config Sharepoint file.

Is this the best place to store this information?

If not..

Where / How should the specific application configuration data be stored in Sharepoint?

Configuration data contains items such as web service locations, etc. Data should only be edited by system administrators.

thanks

+4
source share
3 answers

Web.Config is IMHO, a terrible place to store this kind of configuration information - it's hard to deploy and hard to change, especially if you use multiple web interfaces.

The recommended way to do this is to use the PropertyBag (key / value pairs) through .Properties SPFarm, SPWeb.RootWeb (for site collections), SPWeb, SPList, etc. (depending on the area you need).

MSDN - Manage Customizing Settings for a SharePoint Application

There is a ready-made production code that is available as part of

MSDN - SharePoint Guide Library

See Hierarchical Configuration Manager

This gives you programmatic read / write access to these values. If you want to do this without using the instruction library, you should use something like the following code.

SPWeb web = SPContext.Current.Web; if (web.Properties.ContainsKey("MyProperty")) string myProperty = web.Properties["MyProperty"]; 

If you want the user interface to allow administrators to easily set values, use something like the SharePoint Property Pack Settings

+5
source

The easiest way to do this is to create a sharepoint list that is visible only to the administrator. It can have 3 columns description , title , value . It will save all configuration values. You can also add a link to this list on the site settings page.

+1
source

A web config is always a good place. However, if you want to change this data, you will have to force some kind of recompilation of the site, which is a pain for end users.

Theres a nice little app / solution on codeplex to do with the sum of properties

http://pbs.codeplex.com/

This is a brilliant little application / solution that is related to your central administration.

It should be built in, I think.

Hope this helps.

0
source

Source: https://habr.com/ru/post/1442051/


All Articles