Domanda

In code utilizing SPWebConfigModification what would the typical reasons be for wanting to modify

Two examples I know of are: Adding a Safe control to the config, and making general changes to the appsettings section.

Are there more, if so, what?

È stato utile?

Soluzione

For me pretty much the only real need for web.config modifications are:

  • HttpModules
  • HttpHandlers
  • Assembly redirects
  • Custom navigation provider
  • Custom membership provider
  • Namespace loading (i.e. enable web app to use any control in a namespace / assembly without havign to add a page level assembly / namespace directive on every (layout) page

SafeControls should be set by a solution manifest on deployment to a webapp (WSPBuilder and Visual Studio for SP2010 add a SafeControl entry to the solution manifest automatically when needed).

I prefer to store AppSettings in the SPWebApplication's PropertyBag (or in the PropertyBag of say an SPSite.RootWeb, this way, if need be they can be changed using SharePoint Designer or changed using a custom Application Page (in Central Admin).

Furthermore, SP2010 has the SecureStore Service, which you can use to store user names, passwords and connection strings (pretty much any config value).

Edit:

WCF services i usually deploy using MultipleBaseAddressBasicHttpBindingServiceHostFactory (SOAP) or MultipleBaseAddressWebServiceHostFactory (REST). This way SharePoint handles all settings like security endpoint etc.

Altri suggerimenti

You can pretty much do any modification that your application needs. The benefit of using that class is that it updates the web.config on all servers in your farm. Most common ones are:

  1. Adding Safe Controls
  2. AppSettings (I prefer to use storing configuration in content database though)
  3. Add Authorized types for workflow actions and conditions
  4. Change the trust level
  5. Add a navigation provider or modify existing provider settings
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top