how to deploy web.config modifications in a Sharepoint web application?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 17:37:22

问题


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?


回答1:


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.




回答2:


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>



回答3:


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




回答4:


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.




回答5:


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!




回答6:


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.



来源:https://stackoverflow.com/questions/620978/how-to-deploy-web-config-modifications-in-a-sharepoint-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!