« Previous Next »

Answered Thread: configProtectedData and being in multiple web configs

Last post 07-31-2009 9:35 AM by ThisBytes5. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 07-13-2009, 8:05 AM

    configProtectedData and being in multiple web configs

    Let me first say I’ve only recently installed iis7, think it was Wednesday of last week.

     

    We have a web site that has multiple levels of virtual directories, and the root and each virtual has its own config file that in turn has the configProtectedData and their own connection strings.

     

    In iis6 this all worked just fine. However, in iis7 we get different errors, I say different as I was attempting to resolve the issue and each change I did resulted in a different error. I apologize but I’m unable to get the list of them at this point in time. However, I have determined that removing the configProtecteData fixes the issue, but introduces an install issue.

     

    We have a custom DLL that runs during the install to encrypt the connection strings at the time of install, given that it isn’t aware of the hierarchy of the virtual directory structure an exception is thrown due to the configProtectedData not being there. We are willing to change the DLL but would rather leave it as is if possible.

     

    The above being said is there any way that we can allow the configProtectedData to exist in multiple web configs?

  • 07-16-2009, 12:22 AM In reply to

    Answered Re: configProtectedData and being in multiple web configs

    Hi,

    Could you post the configuration section and the detailed error message here ?

    It is possible allow the configProtectedData to exist in multiple web config files. To avoid duplicate collection entry, you can add the <remove> element to remove the setting inherited from parent hierarchy.

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • 07-20-2009, 3:34 AM In reply to

    • wimoy
    • Not Ranked
    • Joined on 01-23-2008, 9:44 PM
    • Posts 9

    Re: configProtectedData and being in multiple web configs

    Hi ThisBytes5,

    I am the developer of the IIS7 configuration system. I have noticed that you still not replied to Leo Tang's suggestion to post additional information so we can diagnose your issue. I can confirm that the configProtectedData section may be specified in multiple configuration files. In fact, the section is actually a configuration collection, whose semantics are described here: http://learn.iis.net/page.aspx/128/#Collection. Please reply if you would still like assistance with this issue.

    Thanks

  • 07-21-2009, 10:40 AM In reply to

    Re: configProtectedData and being in multiple web configs

    Sorry about the delay in response, I have the email subscriptions enabled which I thought I'd get email updates when there were responses to my post.

    Yes I still need assistance on this, but currently I am unable to reproduce the issue. All my work is on a VM and once I resolve another issue I will be rolling back the disks and starting the process all over to ensure I have all the steps down. At that point I hope to reproduce the issue. Should be in next day or two.

  • 07-27-2009, 9:23 AM In reply to

    Re: configProtectedData and being in multiple web configs

    Ok, again sorry about the delay it's taken longer to roll everything back and reproduce the issues than I thought it would, all part of the learning process I guess.

    As I won't be able to post the real issue I've spent the time setting up a test project/solution. The real issue has to much in it for me to be able to post publicly, also it allowed me to narrow it down quite a bit.

    I did the following:
    1) File new --> Project --> ASP.Net Web Applicaiton
    2) Created new IIS site that pointed to app created in step one, this allowed it to be the root of the site.
    3) Right click on solution --> Add new Project --> ASP.net Web Applicaiton
    4) went to properties and created the virtual directory on the new site. This makes it a child of the first project created
    5) Put following in Default.aspx on root applicaiton, to redirect to child applicaiton

    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.Status =
    "301 Moved Permanently";
    Response.AddHeader(
    "Location", "SubApplicaiton\\Default.aspx");
    }
    </script>


    6) Replaced both Web.Configs with the following:
    <?xml version="1.0"?>
    <
    configuration>
    <
    configProtectedData>
    <
    providers>
    <
    add name="CustomProvider" keyContainerName="CustomKeys" useMachineContainer="true" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </
    providers>
    </
    configProtectedData>
    <
    appSettings/>
    <
    connectionStrings/>
    <
    system.web>
    <
    compilation debug="true">
    <
    assemblies>
    </
    assemblies>
    </
    compilation>
    <
    authentication mode="Windows"/>
    </
    system.web>
    </
    configuration>

    7) go to the new site in IE which results in the following error:
    Error Summary

    HTTP Error 500.19 - Internal Server Error

    The requested page cannot be accessed because the related configuration data for the page is invalid.

     

    Detailed Error Information
    Module IIS Web Core
    Notification BeginRequest
    Handler Not yet determined
    Error Code 0x800700b7
    Config Error
    Config File \\?\t:\Playground\WSepega\DotNet\VS 2008\ConfigRootTest\SubApplicaiton\web.config
    Requested URL http://configtest.com:80/SubApplicaiton/Default.aspx
    Physical Path t:\Playground\WSepega\DotNet\VS 2008\ConfigRootTest\SubApplicaiton\Default.aspx
    Logon Method Not yet determined
    Logon User Not yet determined
    Config Source
       -1: 
        0: 
    
    Links and More InformationThis error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.


    8) In the child app comment the configProtectedData, navigate to the page and all works just fine. I get redirected and have a blank page display.

    Another not of importance:

    %SystemRoot%\system32\inetsrv\appcmd migrate config  <-- this also fails with errors if the section is duplicated in the child config.

    I'd be willing to zip and email the test solution/projects if that will help.

    Thanks
    Wayne

  • 07-28-2009, 5:38 AM In reply to

    Re: configProtectedData and being in multiple web configs

    Hi,

    You can try using the following web.config:

    <?xml version="1.0"?>
    <configuration>
    <configProtectedData>
    <providers>

    <remove name="CustomProvider"/>

    <add name="CustomProvider" keyContainerName="CustomKeys" useMachineContainer="true" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </providers>
    </configProtectedData>
    <appSettings/>
    <connectionStrings/>
    <system.web>
    <compilation debug="true">
    <assemblies>
    </assemblies>
    </compilation>
    <authentication mode="Windows"/>
    </system.web>
    </configuration>

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • 07-31-2009, 9:35 AM In reply to

    Re: configProtectedData and being in multiple web configs

    Thank you, I no longer receive the error when converting it and the app runs.

Page 1 of 1 (7 items)
Microsoft Communities