Question

I have a website in Sharepoint 2007. We use a wsp to deploy our projects. We can deploy dlls, usercontrols, features, but i don't know how to include new lines in the web.config.

Which would be a possible way to make changes in web.config?

Another thing, how can I include resources (resx) in the wsp?

Was it helpful?

Solution

Manually editing the web.config in a multi-server farm is a Bad Idea. Ensuring the web.config files stay in sync on each WFE will become a nightmare quickly.

Using the SPWebConfigModification class to manage web.config changes across the farm is a Good Idea, as changes will be persisted in the SharePoint configuration database, and automatically pushed to every server in the farm.

Having said that, coding against the class can be a pain. Luckily there's a pretty good front-end that's freely available, giving you a configuration screen in Central Administration to add/remove web.config changes.

OTHER TIPS

there is a very easy way to add safe control entries via Solution. The following snippet added to the manifest.xml will make the relevant modifications to the web.config file. To set other values you should do it in a feature receiver using the SPWebConfigModification class.

<Assemblies>
  <Assembly ...>
     <SafeControl Namespace=".." Assembly="..." Type="..." Safe="True" />
  </Assembly>
  ....
</Assemblies>

In addition, if you think about using appSettings from web.config for your site configuration values, you actually have other options as well. For various reasons web.config might not always be the best place to put your values - at least not if a "superuser", etc. is supposed to be able to change them later on. For this, you could instead use a Config Store-feature, which also scales across the farm for multiple front-end servers, etc.:

http://www.sharepointnutsandbolts.com/2008/05/introducing-sharepoint-config-store-for.html

Regarding web.config files...

Web.config is an XML document that contains configuration settings for a web application. It's located in the root directory of a web application, so for SharePoint, it's usually located in the folder C:\Inetpub\wwwroot\wss\VirtualDirectories\SharePoint80, where SharePoint80 is the name of your web application.

Manually making edits to the web.config file is safe as long as you keep the the tags and sections in the right order. Look at this article.

It's also possible to make changes to it programatically, this post should show you how.

Hope this helps.

I think direct web.config manipulation can get tricky when you have multiple servers. If your entire installation is only on a few servers, it just might be easier doing that than trying to make simple web.config changes via code.

Plus, manipulating the web.config directly ensures you have a complete web.config in your source control system. If you use the API to make changes, all you'll have in source control is a bunch of C# code that you hope are bug free!

My advise is not to mess about with any manual modifications through code. Instead, do things the 'SharePoint Way' by placing the modifications in the 12\Config directory as described in Microsoft's SharePoint documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top