tag:blogger.com,1999:blog-4909501580525837098.post8511170387034867000..comments2014-11-24T22:27:46.628-08:00Comments on Stephen Kaye's SharePoint 2007 (MOSS): Master the order of WebConfigModificationsStephen Khttp://www.blogger.com/profile/02829592208885854213noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-4909501580525837098.post-20692317653095733282013-09-11T07:34:13.488-07:002013-09-11T07:34:13.488-07:00Dude,
Your workaround is nothing short of brillia...Dude,<br /><br />Your workaround is nothing short of brilliant, and it saved my bacon. You need to update your code sample though, because as others have already pointed out, your sample does not work as you intended. Here is why:<br /><br />The Name property is used to determine if the element exists at the node specified by the Path proeprty. If the node does not exist, then the XML that you provide with the Value property will get appended to the Path node. With your code sample that means that both the <b>clear</b> and <b>add</b> elements will get added to "configuration/system.web", but you actually want them at "configuration/system.web/httpHandlers".<br /><br />To get the result that you intended, you need to set the properties like so:<br /><br />modification.Path = "configuration/system.web/httpHandlers";<br />modification.Name = "../httpHandlers[1=1]/clear"<br /><br />With the properties set like that, it will still order the modifications as you intended, but the XML in the Value property will get added to the correct node.<br /><br />I know that you said that you never post anything that you haven't implemented, but as I explained, the code that you wrote will clearly not do what you intended. <br /><br />The scenario that I was trying to implement is pretty much the same as yours, and when I tried to implement the code as you wrote it, the XML element got added to the wrong node. It got added to the node specified by the Path property, which makes sense.<br /><br />It wasn't until I read the comments below your post that I was able to get it working.Anonymoushttps://www.blogger.com/profile/12259854088929560269noreply@blogger.comtag:blogger.com,1999:blog-4909501580525837098.post-68875870569871607072010-04-20T06:53:05.987-07:002010-04-20T06:53:05.987-07:00Nice tip! I tried this on SharePoint 2010, and I ...Nice tip! I tried this on SharePoint 2010, and I had to move the [1=1] part into the path, so you get for instance: <br />Path = configuration/system.webServer/modules[1=1]<br />Name = remove[@name='AnonymousIdentification']<br /><br />Otherwise the node was added one level above.Bjørn Stærkhttp://sisharepoint.wordpress.comnoreply@blogger.comtag:blogger.com,1999:blog-4909501580525837098.post-9647320492969417182009-02-06T04:25:00.000-08:002009-02-06T04:25:00.000-08:00name="parent::httpHandlers[1=1]/remove[@path='*.as...name="parent::httpHandlers[1=1]/remove[@path='*.asmx']"<BR/><BR/>this works not correct for remove and not check for present in the web.config.<BR/><BR/>Change to:<BR/>../httpHandlers[1=1]/remove[@path='*.asmx']"<BR/><BR/>and works fine.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4909501580525837098.post-43826214936245166742008-11-16T02:08:00.000-08:002008-11-16T02:08:00.000-08:00I can tell you that I never post anything that I h...I can tell you that I never post anything that I haven't implemented with one exception (<A HREF="/2008/03/execute-entire-page-with-elevated.html" REL="nofollow">Execute entire page with elevated privileges</A>).<BR/><BR/>What I'm highlighting here is the use of a contidition that always equates to true to facilitate ordering of the WebConfigModifications. The exact xpath needed will vary depending on what you are trying to acheive.Stephen Khttps://www.blogger.com/profile/02829592208885854213noreply@blogger.comtag:blogger.com,1999:blog-4909501580525837098.post-31821273553343977452008-11-14T10:07:00.000-08:002008-11-14T10:07:00.000-08:00Have you been able to get this to actually work? ...Have you been able to get this to actually work? I've tried it with EnsureChildNode and it does not place the elements in the expected place.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4909501580525837098.post-68875993667827598502008-11-06T14:47:00.000-08:002008-11-06T14:47:00.000-08:00Great post. But the xpath value in your code didn...Great post. But the xpath value in your code didn't work for me. I had to change it to:<BR/><BR/>SPWebConfigModification modification = new SPWebConfigModification(name, "configuration/system.web/httpHandlers");Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4909501580525837098.post-35353216115396236552008-10-14T00:04:00.000-07:002008-10-14T00:04:00.000-07:00For some reason this did not work for me. I had to...For some reason this did not work for me. I had to still leave the path correct otherwise the new element would not a child of the right parent. To get it to work I changed the name to go to the parent and then to the element it should be under. Like:<BR/><BR/>name="parent::httpHandlers[1=1]/remove[@path='*.asmx']"Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4909501580525837098.post-15952113449442786142008-09-18T15:05:00.000-07:002008-09-18T15:05:00.000-07:00Using this technique, the web.config modifications...Using this technique, the web.config modifications are stored in the correct order; however, there’s an issue when trying to remove the modifications. The modifications are removed from the database when using SPWebConfigModification.Remove(), but the web.config is not updated. Have you experienced this issue?Anonymousnoreply@blogger.com