Web.config modification manager for SharePoint

Search

Accessible SharePoint WebSites
Download ARF

Web.config modification manager for SharePoint

http://blog.thekid.me.uk

The SPWebConfigModification class is used by features to make changes to web.config which need to be applied to all web front ends in the WSS farm. These modifications are 'remembered' by WSS and this allows WSS to remove them when they are no longer required.

Sometimes it is desirable to make modifications to web.config without having to write a feature. If you want to see the stack trace when you get 'An unexpected error has occured' or if you want to add or change an existing 'appSetting' entry, it would be useful to be able to quickly do this via the browser.

To this end I have written a web.config modification manager. This shows the current modifications and allows you to delete them. It also allows you to add new entries which inserts new elements or changes the attributes of exiting ones.

Using this allows you to add changes to web.config on all servers within a farm.

The page also gives examples to assist you in creating the right entries...

The page does have validation to ensure you do not add incorrect entries, which can lead to problems. If you find that you cannot add an entry, which you believe to be valid you can disable the validation by adding ?novalidation=1 to the query string.

There are two options for installation. The first is simply to copy the aspx page (webconfig.aspx) to the ADMIN folder. You can then access the page by going to /_admin/webconfig.aspx from central administration.

The second is to use the installer which will add the webconfig.aspx to the ADMIN folder and also add a link to the 'Application Management' tab in central administration.

Download the aspx page only

Download the solution setup

Once again I will say thank you to Lars Fastrup for providing the solution installer.

UPDATE: You can find an updated version at Harmjan Greving blog.

 

Posted by Vincent Rothwell on Saturday, 24 Mar 2007 01:01  - 24 Comments
Orininally printed from http://thekid.me.uk - Copyright Vincent Rothwell 2007
 

Comments

Sunday, 27 Jul 2008 10:36 by aykSBANWelcYfi
fpDGk2

Sunday, 27 Jul 2008 10:36 by Indonesia
Nice Site! http://google.com

Sunday, 27 Jul 2008 10:37 by jens Balling
I want to add an element inside configuration/runtime/asssemblyBinding! But the assemblyBinding element is within another xml-namespace! What is the path to this element? you can't just use configuration/runtime/asssemblyBinding since it returns nothing.

Sunday, 27 Jul 2008 10:37 by Vince
Jens, Unfortunately the class (SPWebConfigFileChanges) which performs the web.config updates does not use namespaces. This means that you cannot change any nodes which use a namespace. I would suggest creating your own SPJobDefinition which performs the update. Use Reflector to look at SPWebConfigFileChanges to see how Microsoft does it. --Vince

Sunday, 27 Jul 2008 10:37 by Reza Alirezaei
It is a great tool. Thanks for sharing. Have you tested your tool when you extend the web application to other zones such as inernet,custom,extranet and etc? I know that removing SPWebConfigModification won't work for extended apps so I assume that the same issue exists here. I haven't installed your tool , but by looking at the code I could see the same issue. Reza Alirezaei, Moss MVP Blog: http://blogs.devhorizon.com/reza

Tuesday, 5 Aug 2008 01:18 by Usman Afzal
Hi, Nice Effort but i need to ask something, I am developing a application that needs to add some links to Share Point Central Administration site and for somereason i need to modify the web.config of Share Point Central Administration. How could I do this. ? Kind Regards, God bless You.

Wednesday, 8 Oct 2008 03:16 by vIceBerg
Maybe you should remove the require="MOSS" in your .config file because it's not required.

Tuesday, 14 Oct 2008 03:25 by Bart Zuidgeest
I installed using your installer and I'm getting this every time I try to use it. The error is in dutch so it had to translate.... cannot insert web.config-changes in file configuration/system.web/pages. cannot find node C:\Inetpub\wwwroot\wss\VirtualDirectories\portal.dev.svc.local80\web.config in het web.config-file. at Microsoft.SharePoint.Administration.SPWebConfigFileChanges.ApplyModificationsWebConfigXmlDocument(XmlDocument xdWebConfig, String filepath) at Microsoft.SharePoint.Administration.SPWebApplication.ApplyWebConfigModifications() at Microsoft.SharePoint.Administration.SPWebService.ApplyWebConfigModifications() at ASP._admin_webconfig_aspx.AddEntry(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) I mistyped the first time I used it. But now I get this error every time. Even If I use the examples included on the page. Same one every time. Any thoughts?

Monday, 24 Nov 2008 10:25 by Brian
Hi! it looks like the links to the installer aren't working.. Do you know where I can find it??

Monday, 24 Nov 2008 10:27 by Brian
nevermind! I opened my eyes and found the link that works! lol

Sunday, 11 Jan 2009 03:05 by Web Developer
Hi, Ur code is awesome.I learnt something new today. Thanks for your effort. really appreciated. Can i used this to read web config values from a site created using site collection and child sites. I mean a web page from a site can access this info right? also... Can I read it from a Timer Job Definition Class also. I am writing a Timer Job Definition and need to get the sql server connection string value in the code.

Tuesday, 10 Feb 2009 02:46 by
Hi, awesome codes!!! Thanks for sharing.

Thursday, 19 Feb 2009 09:11 by Muthu
Hi, Thanks for code. It worked great. But when i was making changes, i made it to the site rather than the Central Admin on my top right corner drop down. Did I do that right? Do i need to do the same for all web front ends individually in that case? Thanks, Muthu

Wednesday, 8 Apr 2009 03:38 by BobC
Excellent. This type of feature should be included in WSS due to how important and difficult it is to keep farms in sync. Thanks!

Thursday, 9 Apr 2009 08:23 by BobC
Excellent. This type of feature should be included in WSS due to how important and difficult it is to keep farms in sync. Thanks!

Thursday, 7 May 2009 01:06 by OlivierC
Very nice feature. Thank you for this great job.

Tuesday, 19 May 2009 04:19 by Charu
Excellent feature. I want to add assembly in <assemblies> node in web.config. I am using the following values but getting the error "Invalid value: Expression must evaluate to a node-set." Modification Type : EnsureChildNode Modification Path : configuration/system.web/compilation/assemblies Modification Name : <add assembly="CrystalDecisions.CrystalReports.Engine,Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" /> Modification Value : <add assembly="CrystalDecisions.CrystalReports.Engine,Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" /> Can I add this using your solution?

Tuesday, 19 May 2009 04:52 by Charu
It is resolved after i changed name to add[@assembly="CrystalDecisions.CrystalReports.Engine,Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"]

Tuesday, 9 Jun 2009 08:09 by Donald Ashworth
I am receiving the following error message; "Name is not compatible with the value" I am attempting to add a connection string to the web.config file under "configuration/appSettings". Modification Type: EnsureChildNodes Modification Owner: SolutionABC Modification Path: configuration/appSettings Modification Name: add[@key="SolutionABC"] Modification Value: Data Source=ServerOne;Initial Catalog=SolutionABC;User ID=SolutionABC;Password=SomePassword; Everything looks right. I'm thinking perhaps 1) I am dealing with a permissions issue, or 2) the path is not correct in the web.config file. Not sure. Any ideas? Thanks, Don

Friday, 12 Jun 2009 10:21 by Eric LE ROY
I installed your page but when i want to add a new key to appSettings section i always get the floowinf error Invalid value: Expression must evaluate to a node-set If I reload the webconfig.aspx page, the new key is displayed and accessible in web site Any idea ? NB : sorry, my english is awaful

Friday, 12 Jun 2009 10:22 by Eric
I installed your page but when i want to add a new key to appSettings section i always get the following error Invalid value: Expression must evaluate to a node-set If I reload the webconfig.aspx page, the new key is displayed and accessible in web site Any idea ? NB : sorry, my english is awful

Thursday, 9 Jul 2009 09:39 by Dhanasekaran R
Hi, Can I get the source code of this solution package.

Wednesday, 7 Apr 2010 09:11 by Lifesaver
I was programatically adding webconfigmodifications, but had the name wrong, then corrected the name, but had a bunch of orphaned entries. My code was adding duplicates and triplicates. With this tool I was able to see and delete the old ones and now all is good with my farm - thanks man

Monday, 10 May 2010 10:34 by Mark C
I'm using SharePoint 2010 and the installer complained about the version. Any chance you'll have a 2010 version available soon?



Url

Email

Comments