0

Is any way how to find you whether some node exists in web config? SPWebConfigModification? or some other class? I belive there must be way how to find it out.

Thanks.

6
  • Why do you want to check that? And which web.config should SharePoint check? There can be any number of web applications and servers. May 21 '12 at 19:02
  • Server is the only one, and application which is activating this feature. This I have solved bud I need to add/remove sections with custom type, and also write those sections into sharepoint config, which is for this app (shared) (as I understand, each app dosen't have own config). I guess this is not good way how to do it. However, ps scripts should be able much easier perform these updates.
    – Peter P
    May 22 '12 at 6:58
  • SPWebConfigModification is the way to add entries to the web.config in SharePoint, if made right they'll make sure that the sections are added when the first feature needing them are activated and removed when the last feature needing them are deactivated. You don't need to know if the section already exists you just need to specify that you need it. May 22 '12 at 8:52
  • I need to inject custom values for application not for features. Before inject I have to be sure that I'm not going to insert some duplicit configuration. In sharepoint isn't any way how to force ConfigurationManager to point to application config? These stuffs around config are totaly disaster ... God bless ASP.NET MVC
    – Peter P
    May 22 '12 at 11:22
  • What do you mean by application not feature? SPWebConfigModifications will not cause multiple entries. It's SharePoint so it's intelligent, not ASP.NET where you have to do everything yourselves. May 22 '12 at 11:29
1

The SPWebConfigModification, as you may already be aware, is used purely to make changes to the web.config in SharePoint which can then be propagated across a farm.

To check for the existence of a section you may be able to use the WebConfigurationManager from the System.Web.Configuration namespace (System.Web assembly) - see http://msdn.microsoft.com/en-us/library/system.web.configuration.webconfigurationmanager(v=vs.90).aspx.

Hope this helps.

2
  • maybe ... I've lost few days with feature deployment ... I'm going to write ps scripts, and hope one day I will forget this sharepoint nightmare... this is crazy technology ...
    – Peter P
    May 21 '12 at 14:38
  • I think technology is very good. You need some training how to create custom solution and deployment in SharePoint.
    – user994521
    Mar 11 '13 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.