Editing web.config file from a feature using linq

  • Editing web.config file from a feature using linq gaotter

    I have custom web.config functionality that uses Linq to merge elements into a web.config based on a template file. I would like to use this in a feature so I can get it to merge all web.configs in a load balancing environment. I know there is something called SPWebConfigModification, but the extent of the elements to add is large and I need it to be more dynamic like the template solution. I know I could run it on each front end server, but it would be better in a feature or solution.

    Is there a way to get access to the web.config in a feature in SharePoint 2007?

  • If you're really sure you don't want to use SPWebConfigModification, you could look at SPWebService.ApplyApplicationContentToLocalServer() - this has the capability of merging entire sections into config files, but has the following caveats:

    • Only applies to the local server (clue is in the name!)
    • Must be called by a local administrator

    The combination of these two caveats means you can't use the normal pattern of using a timer job to ensure something executes on all servers in a farm. If you were happy to write say, a windows service which would call this web service, well that would get you round it.

    However my recommendation would be to stick with SPWebConfigModifcation. Regardless of how big a custom section is, it's going into the web.config as a child node of a node somewhere so can be added as an 'EnsureChildNode'. It would certainly be possible to combine your merge functionality with SPWebConfigModification (i.e. pass in the merged XML to calls to SPWebConfigModification), and then you can be sure the change will applied across the whole farm. Also, it's easy to write code to remove the changes (e.g. in the Feature Deactivated event if your host code is a Feature receiver).

feature deployment spwebconfigmodification web-config linq
Related questions and answers
  • it to the default.aspx home page. I would be happy either way. Note: I want to be able to activate this on existing site, I dont want to create a new Site Definition. Here is what I have tried: Feature Receiver...), then there doesn't seem to be a way to just get a reference to the page, it always wants to overwrite it with a new file. But I dont want to do that, I just want to add a Web Part to the existing page. See my...I've been hitting my head against a wall on this one for the last couple of days. I have a pretty simple requirement but I cant see how it can be achieved within a Sandboxed solution. I'm depressed

  • does activate the webpart but i also want to remove it when deactivating it.(So i know i need to add something to the FeatureDeactivating So i created a Feature With Reciever template and added...; i--) { // format name to look like a feature name string webpartName = list.Items[i].Name; webpartName = webpartName.Substring(0, webpartName.IndexOf... deactivate it it doesn't remove it but i get error: Failed to instantiate file "myStoreComms.webpart" from module "WebPartPopulation": Source path "myStoreComms.webpart" not found. Any ideas.. .what

  • (I have also asked this question on Stack Overflow) I have a SharePoint feature I'm using to add some custom aspx files to the Pages Library. When I activate the feature, I can visit the pages in-browser and they are visible in SPDesigner, but when I "View All Site Content" they are not there. Why is this the case? The Feature's Elements File: <?xml version="1.0" encoding="utf-8"?> <Elements Id="9e85eb79-6d8d-4ff3-b0d4-64d55c3bb577" xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="Pages" Url="Pages"> <File Path="Example.aspx" Url

  • I have a webpart that is part of a larger solution, deployed as a WSP using WSPBuilder. I can see the SafeControl entry in the web.config and can see that the assembly has deployed to the GAC. The solution reports as installed OK in Central Admin and the feature is activated at the site collection. When I attempt to add the webpart to a page, I'm getting an error stating that the "Type could not be found or is not registered as safe." I have removed this solution from MOSS and completely re-created the webpart, in case I've messed up GUIDs or something. I'm not sure what to check next. Any

  • I was reading someone else's post on comparing some of the wsp building tools when someone stated you could reverse engineer something like a .stp file created site into source files (for example the fab-40 application templates). I would really like to know how to do this as there are a few of the templates that are like 80% of what I need to build a solution. I think it would have been awesome had MS released the source files for all 40 of the templates!

  • and into a feature, then reference the feature from ONET. Once this was done, generate a series of stsadm deactivatefeature and activatefeature commands to get the home page the way we needed for all existing sties. New sites would pick it up via the feature. When I do this I can deactivate and reactivate the feature to correctly replace the home page with the "latest version". However, when I...." error message. Digging through the 12\Logs, I found a little more detail: Failed to find a suitable list for tag in module for file 'Pages/default.aspx' given List attribute 'Lists

  • I am unable to update the record in SharePoint 2010 using new linq feature. follwoing in my code please review it. AbsentTrackingSystemEntitiesDataContext ctx = new AbsentTrackingSystemEntitiesDataContext(spWeb.Url); ctx.ObjectTrackingEnabled = true; HolidaysItem Holidayobj = GetHolidays(HolidayID, ctx); // get the specific record to be update. if (Holidayobj != null) { Holidayobj.Title = "test"; Holidayobj.HolidayDate = DateTime.Today; Holidayobj.Description = "test holiday

  • I want to change the look and feel of my SharePoint Server 2010 site. I have used office Power font to create my custom theme as a .thmx file. I just wanted to know how to use the custom style in SharePoint Server 2010. Like we did earlier in Office SharePoint Server 2007 by creating a theme folder. I want a solution so if I deploy my theme into server 2010 I will not get trouble. Thanks

  • Full disclosure: Sharepoint development noob. I currently have 3 custom web parts built in an SP solution in VS2010. I build and deploy my project out to our local Sharepoint dev box. However, after deploying, only the first 2 custom web parts show up under the Custom category in the "insert web part" ribbon section. I checked the elements.xml file for all 3 webparts, they're all set up to be listed under the custom group. Any ideas on how I can debug this? Any constructive advice is greatly appreciated. Home elements.xml <?xml version="1.0" encoding="utf-8"?> <Elements xmlns

Data information