SPWebConfigModifications Duplicate entries, applying to all Web Applications and not removing entries

Hi,
Hopefully someone can offer some advice, I may be missing something obvious here.
I'm currently trying to write a feature event receiver to apply web.config modifications that are required by a recent project. 
The feature is web application scoped & it doesn't activate by default on deployment, currently testing with a very small addition isn't working at all, I've followed numerous posts about duplicate entries & items being removed, none of which have
helped.
Here is my code;
public override void FeatureActivated(SPFeatureReceiverProperties properties)
            SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
                SPWebConfigModification Modification = new SPWebConfigModification();
                Modification.Owner = "ConfigUpdater";
                Modification.Path = "configuration/appSettings";
                Modification.Name = "add[@key='Test']";
                Modification.Sequence = 0;
                Modification.Value = "<add key='Test' value='Server=TestServer;Database=TestDB;Trusted_Connection=True;' />";
                Modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
                if (!webApp.WebConfigModifications.Contains(Modification))
                    webApp.WebConfigModifications.Add(Modification);
                    webApp.Update();
                    webApp.WebService.ApplyWebConfigModifications();
        // Uncomment the method below to handle the event raised before a feature is deactivated.
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
            SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
            Collection<SPWebConfigModification> modsCollection = webApp.WebConfigModifications;
            int count = modsCollection.Count;
            for (int i = count - 1; i >= 0; i--)
                SPWebConfigModification mod = modsCollection[i];
                if (mod.Owner == "ConfigUpdater")
                    modsCollection.Remove(mod);                   
            webApp.Update();
            webApp.WebService.ApplyWebConfigModifications();          
Upon activation on 1 web app, the entry gets added twice to the web.config of every web application in the farm & upon deactivation the entries remain in the web.config files.
On activation, after this line, webApp.WebConfigModifications.Add(Modification); the webApp is updated to include the entry & only once, however 2 entries for it appear in the web.config files & as mentioned for every web application.
On deactivation, after updating the web app, the modification is removed, however it remains in the web.config files.
I'm wondering if the code actually works, as I can't see anything wrong & if there is some caching occurring somewhere which is applying the extra line/s upon calling ApplyWebConfigModifications.
Any help on this would be much appreciated.
Thanks,
James

Hi James,
Per my understanding, there is an entry gets added twice to the web.config file of every web application in the FeatureActivated event.
As a common practice, I suggest you debug your code to see how it works during the process, it will provide more information for a better troubleshooting.
Also, you can test the code in a Console Application to see if it will work as expected.
Thanks         
Patrick Liang
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected]

Similar Messages

  • Site Map providers xml's throght out all web applications.

    Hi all,
    How to
    site map providers to all web applications. each and every site map provider should apply to each web application.
    ex: we can apply single site map provider(for top navigation) to one web application. but If we take 5 site map providers, how to apply these site map providers to 5 web applications through code.
    If any doubts, please let me know.
    Please help me on this.

    Hi,
    According to your post, my understanding is that you want to customize a top navigation and apply it to all web application.
    The following articles for your reference:
    Building a Custom Site Map Provider
    http://www.codeproject.com/Articles/96461/Building-a-Custom-Site-Map-Provider
    Web Application Navigator for SharePoint
    http://wan.codeplex.com/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • How to deploy one common filter for all web applications

    I want to deploy a filter for all the web applications i have running on weblogic server. I don't want to deploy the filter just within a specific web
    context, was able to achieve this on tomcat as it provides a common web.xml
    which will apply to all web apps. But i don't know how to achieve this on Weblogic. Your help would so much appreciated.

    Thanks Vidyut! You've answered my question.
    I placed the jar file in the $CATALINA_HOME/shared/lib directory. But where should I place the taglib TLD file? And how should I reference it in web.xml?
    Currently, my web.xml is as follows and it doesn't work.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <taglib>
    <taglib-uri>http://abc.com</taglib-uri>
    <taglib-location>c:\Tomcat\shared\lib\mytags-taglib.tld</taglib-location>
    </taglib>
    </web-app>
    Thanks again!
    Joe

  • Launch All Web Applications in browser using PowerShell

    Hi Admins,
    I am working on a Script where I should be able to launch all the web applications in the browser to open in tabs.
    I have worked out with the following script and was able to come upto an extent where I am able to launch the Internet Explorer.But ....only 1 web app opens up and throws an error message :
    Exception calling "Navigate" with "1" argument(s): "The interface is unknown. (Exception from HRESULT: 0x800706B5)"
    Below is my script
    Add-PSSnapin Microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
    $webApps = Get-SpWebapplication
    foreach($webapp in $WebApps){
    $URL = $webapp.URL
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Navigate($URL)
    while ($ie.busy -eq $true) {
    Start-Sleep -Milliseconds 600
    $ie.Visible = $true
    Can anyone help me know where I am making the mistake ?
    Regards

    Hi,
    As I understand, you want to lunch all web applications in browser using PowerShell.
    I can achieve it by the PowerShell code below:
    foreach($webapp in $WebApps){
    $ie = New-Object -ComObject InternetExplorer.Application
    $URL = $webapp.URL
    $ie.Navigate($URL)
    $ie.Visible = $true
    You can try it and check it if can work.
    For the error message, I recommend to run the SharePoint Management Shell as administrator or turn off User Access Control and then check how it works.
    Best regards
    Sara Fan
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]
    The above code will open 3 different browser. OP requested to launch all web application in different tabs. To achieve this we need to use the code below
    $webApps = Get-SpWebapplication
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Navigate($webApps[0].URL)
    for($i=1; $i -le $WebApps.length-1; $i++)
    $ie.Navigate2($WebApps[$i].URL,0x10000)
    $ie.Visible = $true
    Regards Chen V [MCTS SharePoint 2010]

  • Make a jar file availlable for all web application at deployement time

    Hi !
    Is there a way to make a jar file availlable to all web application included in a .ear file. I know that i can manually copy the jar under (OC4J_HOME)/j2ee/home/lib , but can i create a package that have those web application ( lets say 4 ) and also the common jar file, deploy the that .ear file and make my jar file automatically availlable for all the deployed web application ? or is there a special command that i can use to copy that jar to the (OC4J_HOME)/j2ee/home/lib while deploying the .ear file ?
    i tried adding a manifest file with the classpath option but this seem to work only with jsp...
    thanx for your audience...

    Open the file %J2EE_HOME%/applcation-deployments/your-app/orion-application.xml. Add a tag like the one below:
    <library path="location_of_my_library.jar" />
    This will make the JAR availible to only your application, and the modules within it, and no others.
    Rob Cole
    Oracle

  • Web application and desktop application?

    Hi everyone,
    I am new to this platform.I have a basic doubts that whats the difference between developing application in flex as a web application and desktop application from programming point of view?Can we use same code in both cases?
    Please guide me....
    Thanks

    Hi and welcome,
    The main difference between a web application and a desktop application is that web applications do not have access and can't manipulate your local system ( you can't open a window that displays all your local files, you can't delete, rename, edit local files and so on ). Obviously, this is just one difference, there are many more ( the best would be if you google for "web aplication vs desktop application" because the same rules apply for 99% if not all the platforms you can find out there ).
    Desktop applications can have full control of your local system ( obviously, we have to take in consideration the platform we are using because since AIR is quite new in the desktop application field it is also more limited than other languages that have been used successfully to create desktop applications for years and year; like ce C# or C++ and so on ).
    Another important difference is that desktop applications usually need to be installed in order to function where on the other hand, web applications can run in the browser without you having to install the aplication you are about to view on your computer ( in some cases, like of the Flash and Flex platforms, you only require a "special player" that can display the content you are trying to access... for Flash and Flex applications you need the Flash Player installed for your browser ).
    So, before jumping into a project/platform you need to know your target. If you goal is to offer a fast, easy to access and no install required application to your users then you'll usually go with a web application. If your application needs to work with local files, maybe local databases, or it needs more control over the user's PC and so on, then you'll most likely go with a desktop application.
    With kind regards,
    Barna Biro

  • Web application and site collection not accessibe

    I have created a web application and a site collection. But when I tried to access the site by browser on the server the page cannot be displayed or the server cannot be found. What should I configure? Please say by detailed steps.

    I created a host header extranet.xxx.xx and alternate access mapping is ok. But still I'm not able to access the site by http://server name:port no. It gives The web page cannot be found or this web page can't be displayed.
    Now when I try with Firefox with http://server name:port no, it gives
    "Bad request - Invalid hostname
    HTTP Error 400. The hostname is invalid."
    More: if I go to Alternate Access Mappings > Add Internal URL:s > Save is grayed out.
    You have two options,
    Option 1 : Accessing the web application without any host header name and  with the port no you have created.  (ex: (http://server1:5500 )
    Option 2. Accessing it with the host header name (ex:http://mywebapp.contoso.com)  you have created for which you need to create a DNS and set an AAM accordingly in the corresponding zone.
    For the option no 1. you need to have a host header in IIS which would be created by default while you create a web application and it should be like this unless you did nit change it. http (Type)---blank host name--All Unassigned in the IP section---and
    the port no in which you have created.
    PS : If you have one more IP address in the server, its good to set the same IP address which is set for server for the name resolution to happen properly.
    If you have n't specified the hostheader while creating the web application, then you need to add it manually with the existing one which is there for option no 1. It should be added as below. http---Mywebapp.contoso.com--IP address in which you have created
    the DNS and Port 80.
    If AAM save is grayed out, check it from some other browser. Also Hostname invalid clearly implies that there is some problem with the name resolution. Check whether you could ping the webapplication from the server where you are trying to access it.
    Veeramani.S

  • There is an inconsistency between the authentication mode of target web application and the source web application after migrating to claims

    I've had my farm upgraded from SP2010 to SP2013 for over 6 months now and all is well, however, I was refreshing my staging environment from production and I noticed that one of the databases still shows these errors when I run test-spcontentdatabase:
    Category             : Configuration
    Error             : False
    UpgradeBlocking : False
    Message           : The [SharePoint Web App] web application is configured with claims authentication mode however the content database you are trying to attach is intended to be used against
    a windows classic authentication mode.
    Remedy              : There is an inconsistency between the authentication mode of target web application and the source web application. Ensure that the authentication mode setting in upgraded web application is the
    same as what you had in previous SharePoint 2010 web application. Refer to the link "http://go.microsoft.com/fwlink/?LinkId=236865" for more information.
    This doesn't make sense considering I converted the production web application to claims during the upgrade and then verified all sites were working with claims logins. I also verified that existing AD user identities were converted to claims by checking out
    the database tables. Yet test-spcontentdatabase still thinks there is a mismatch here.
    My farm is SP1 and no further CUs. The point of this particular refresh is so I can update to the November CUs in my test farm. Anyone else see this? Seems like it's a bug/safe to ignore because my stuff is working.
    Thanks,
    Aaron

    See:
    http://thesharepointfarm.com/2014/11/test-spcontentdatabase-classic-to-claims-conversion/
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Registering Web Applications and accessing common files

    If I create 3 web applications and have a seperate folder for common jsps
              that the jsps in these 3 web apps include, how can I access the jsps and js
              in this common folder? The JSP compiler was able to compile. The folders I
              created are all under the applications directory, including the common
              folder. I use the inclide file directive with ../common/scripts.js and the
              compiler could not recognize the location.
              Thanks!
              Kenny
              

              If you application folder like:
              application/
              webApp1/
              webApp2/
              webApp3/
              common/
              You may try /common/scripts.js
              "Kenny Kon" <[email protected]> wrote:
              >If I create 3 web applications and have a seperate folder for common
              >jsps
              >that the jsps in these 3 web apps include, how can I access the jsps
              >and js
              >in this common folder? The JSP compiler was able to compile. The folders
              >I
              >created are all under the applications directory, including the common
              >folder. I use the inclide file directive with ../common/scripts.js and
              >the
              >compiler could not recognize the location.
              >
              >Thanks!
              >
              >Kenny
              >
              >
              

  • Web Application and Serialization

    Hi, i have a problem with a web application that is running on an Application server (BEA WebLogic 7.0). I have only the war file of the web application and i must know if in this war there is a class that is not serializable.
    How can i find it ? Is there a tool that can help me to find not serializable classes ?
    Thanks.
    claudiozx2006

    One way to do that is to decompile Java classes with Java decompiler and see which one doesn't implement Serializable interface. Here is a link to a good decompiler: http://www.kpdus.com/jad.html

  • Web application and Scanner

    Web application (ADF-application) and Scanner (device that optically scans images, printed text)
    how to implement a scan from a web application and the ability to preview the scanned document (in the ADF-application) before uploading to the server.

    Oracle has a product, which I worked on, for imaging. It may or may not be what you need.
    http://www.oracle.com/technetwork/middleware/webcenter/content/index-090652.html

  • Extending Web Application - File Not Found

    A quick search with no results and a ton of frustration are leading me here...I am attempting to use the very basic "Extend" functionality for a Web Application. We are trying to at the least add SSL/443 to SharePoint, if not convert entirely to
    443.
    I have tried simply extending the Web Application, or deleting the IIS Site (from Manage Web Applications -> Delete -> Remove SharePoint from IIS Web Site) and then extending the Web Application. Both are failing with the same error "File not
    found." A review of the ULS logs shows that the site is failing to find the web.config for the brand new IIS site it should be creating...which I guess makes sense, but shouldn't it be creating this file?
    I am tempted to mess around with the newly created site in IIS to make it work, but we are doing this in Dev as a proof of concept to do this in production. Needless to say, this needs to become much more reproducible before we'd even consider doing it in
    production.
    Some things I've tried:
    Extending a Web Application with an existing site
    Extending a Web Application without an existing site
    Creating a new Web Application and extending existing port 80 site
    Creating a new Web Application and extending after deleting existing port 80 site
    I haven't tried creating a site 443 out of the gate mainly because I am afraid this functionality failing could be an indication of something wrong with the farm and want to fix this correctly, rather than deleting a Web Application and creating it 443 from
    the get-go. Also, this method would obviously involve downtime.
    System.IO.FileNotFoundException: Could not find file 'C:\inetpub\wwwroot\wss\VirtualDirectories\ConstructionProjectsDev.agoc.com443\web.config'.
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
    at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
    at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
    at System.Threading.CompressedStack.runTryCode(Object userData)
    at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
    at System.Xml.XmlTextReaderImpl.OpenUrl()
    at System.Xml.XmlTextReaderImpl.Read()
    at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
    at System.Xml.XmlDocument.Load(XmlReader reader)
    at System.Xml.XmlDocument.Load(String filename)
    at Microsoft.SharePoint.Administration.SPAspConfigurationFile.ApplyZoneSettingsToWebConfig(Uri responseUri, SPIisSettings settings)
    at Microsoft.SharePoint.Administration.SPWebApplication.Provision()
    at Microsoft.SharePoint.ApplicationPages.ExtendWebFarmPage.BtnSubmit_Click(Object sender, EventArgs e)
    at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    Thanks,
    Chris P.

    A quick search with no results and a ton of frustration are leading me here...I am attempting to use the very basic "Extend" functionality for a Web Application. We are trying to at the least add SSL/443 to SharePoint, if not convert entirely to
    443.
    I have tried simply extending the Web Application, or deleting the IIS Site (from Manage Web Applications -> Delete -> Remove SharePoint from IIS Web Site) and then extending the Web Application. Both are failing with the same error "File not
    found." A review of the ULS logs shows that the site is failing to find the web.config for the brand new IIS site it should be creating...which I guess makes sense, but shouldn't it be creating this file?
    I am tempted to mess around with the newly created site in IIS to make it work, but we are doing this in Dev as a proof of concept to do this in production. Needless to say, this needs to become much more reproducible before we'd even consider doing it in
    production.
    Some things I've tried:
    Extending a Web Application with an existing site
    Extending a Web Application without an existing site
    Creating a new Web Application and extending existing port 80 site
    Creating a new Web Application and extending after deleting existing port 80 site
    I haven't tried creating a site 443 out of the gate mainly because I am afraid this functionality failing could be an indication of something wrong with the farm and want to fix this correctly, rather than deleting a Web Application and creating it 443 from
    the get-go. Also, this method would obviously involve downtime.
    System.IO.FileNotFoundException: Could not find file 'C:\inetpub\wwwroot\wss\VirtualDirectories\ConstructionProjectsDev.agoc.com443\web.config'.
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
    at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
    at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
    at System.Threading.CompressedStack.runTryCode(Object userData)
    at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
    at System.Xml.XmlTextReaderImpl.OpenUrl()
    at System.Xml.XmlTextReaderImpl.Read()
    at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
    at System.Xml.XmlDocument.Load(XmlReader reader)
    at System.Xml.XmlDocument.Load(String filename)
    at Microsoft.SharePoint.Administration.SPAspConfigurationFile.ApplyZoneSettingsToWebConfig(Uri responseUri, SPIisSettings settings)
    at Microsoft.SharePoint.Administration.SPWebApplication.Provision()
    at Microsoft.SharePoint.ApplicationPages.ExtendWebFarmPage.BtnSubmit_Click(Object sender, EventArgs e)
    at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    Thanks,
    Chris P.

  • Can you help me to retrieve my applications. In iTunes I accidentally clicked the Restore button in the Summary screen. It restored the original settings and I lost all my applications and don't know if it is possible to retrieve them.

    Can you help me to retrieve my applications. In iTunes I accidentally clicked the Restore button in the Summary screen. It restored the original settings and I lost all my applications and don't know if it is possible to retrieve them.

    All apps on an iPhone, iPad, or iPod Touch should be in your iTunes library on your computer.
    You can re-download all 3rd party apps and you won't be charged again for a purchased app as long as you use the same iTunes account to re-download the apps that was used to purchase the app originally.
    http://support.apple.com/kb/HT2519
    Do this with iTunes on your computer. After you have re-downloaded every app one by one, select Sync Apps under the Apps tab for the device's sync preferences along with selecting the apps below that you want transferred to the device followed by a sync to re-install the apps on the device.

  • HT204053 i just brought new i phone 5 yesterday and now i can see all paid applications and i dont use or have credit card also now how i can buy applications which are important for me? can i buy them online? or use debit card

    i just brought new i phone 5 yesterday and now i can see all paid applications and i dont use or have credit card also now how i can buy applications which are important for me? can i buy them online? or use debit card and trust me all my friends are regretting buying phone because of this problem.Kindly help.Cant it can be deducted from our mobile charges?i would be much easier then

    You can buy apps using iTunes Gift cards without needing to register your debit card.
    http://store.apple.com/us/personalize/itunes

  • HT1977 I'm a iPhone 4s and new iPad 3 owner.  I'd like the apps and organization I've invested in the iphone to be exactly transfered to the ipad.  Is this possible?  Will all the applications and folders match exactly?  Thank you for your help

    I'm a iPhone 4s and new iPad 3 owner.  I'd like the apps and organization time I've invested in the iphone to be exactly transfered to the ipad.  Is this possible?  Will all the applications and folders match exactly?  Thank you for your help

    Restore the latest iPhone backup you made to the iPad.

Maybe you are looking for

  • Mail crashes when on message with attachment

    I can open mail without any problems, but when I select a message with an attachment, mail quits. Help ! Process: Mail [12673] Path: /Users/dsoubliere/Desktop/Applications/Mail.app/Contents/MacOS/Mail Identifier: com.apple.mail Version: 3.3 (926.1) B

  • Tutorial Oracle DB 64 bit

    Hi, Where I can find tutorial installing 64 bit Oracle DB 11g on Windows Server 2008 R2 64bit and then connecting to Data Mover using 32 bit Oracle client ?

  • Premiere elements  10

    Hello, a film made in adobe premiere elements 10.0 , can not be transported= exported  to tape (digital video) ,   i can well import a video from tape to PC   i'm  working with firewire( with texas instruments chip ) unther windows 7 64 bit   camera 

  • Multi-master replication and replica_update_ruv: unable to update

    I'm running Sun ONE 5.2 DS on Solaris 8 with multi-master replication comprising of 2 masters (M1 & M2) and 2 consumer replicas (R1 & R2). M1 sends updates to consumers R1 and R2, M2 sends updates to R2 and R1 (and offcourse M1 to M2 and M2 to M1). R

  • Point Light and Glow not working

    I have ran into a strange issue recently. For some reason, certain built in features aren't working for my CS6 AE. When I try and use a point light or the glow effect nothing happens. No matter how much I tweak the settings it nothing happens. Has an