locked
changes to web.config files versus applicationhost.config RRS feed

  • Question

  • User-1202834629 posted
    How do I make changes to web.config files versus applicationhost.config? As in previous posts, I'm using IAppHostWritableAdminManager to configure websites\applications etc.  I can make changes to applicationhost.config using that, but I don't know how to make changes to an individual application.

    As an example, if I try to set the default document of a application I only see the change in applicationhost.config.  I want to see the change in the web.config for the application.  I think the problem might be that I'm using the following:

    hr = spAppHostAdminManager->GetAdminSection(L"system.webServer/defaultDocument",L"MACHINE/WEBROOT/APPHOST/MytestApplication", &pSites);

    This seems to look in the defaultDocument sections of applicationhost.config.  Perhaps I'm using the wrong value for the second parameter of GetAdminSection?  Please let me know if you have any suggestions.

    Wednesday, November 1, 2006 11:51 AM

Answers

  • User511787461 posted

    There is no section named system.webServer/security - it is a section-group, there are sections named system.webServer/security/authentication/anonymousAuthentication etc

    It is not easy to tell from just looking at the config file what is a section vs a section-group vs an element inside a section - to figure that out, look at the *schema.xml files in %windir%\system32\inetsrv\config\schema\ - in particular at IIS_schema.xml in this case.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Monday, January 8, 2007 7:32 PM

All replies

  • User511787461 posted
    You have to use IAppHostWritableAdminManager::put_CommitPath to control where the changes get written to - also for sections which are locked at a higher level (like most system.webServer sections are in applicationhost.config by default) - you will have to first unlock them there to be able to commit to a lower config file.
    Wednesday, November 1, 2006 2:21 PM
  • User-1202834629 posted

    Thanks for responding so quickly.  Maybe its a dumb question, but I'm a bit confused about what the CommitPath should be.  I tried the following:

    hr = spAppHostAdminManager->put_CommitPath(L"c:\\Windows\\System32\\inetsrv\\config\\test\\web.config")

     also tried this:

    hr = spAppHostAdminManager->put_CommitPath(L"MACHINE/WEBROOT/APPHOST/MytestApplication");

     but then I get the error "hr 0x80070002 The system cannot find the file specified." when I call

    spAppHostAdminManager->CommitChanges();

    Any ideas?

    Wednesday, November 1, 2006 2:56 PM
  • User511787461 posted
    It would be something like "MACHINE/WEBROOT/APPHOST/Default Web Site/MytestApplication" - your config path for the open also needs to be fixed.
    Wednesday, November 1, 2006 6:46 PM
  • User-1202834629 posted

    I am now trying to set authentication properties for a website, but I am having trouble getting the element via code.  I see the section I want in applicationhost.config, but when I try the following, it fails:

    hr = spAppHostAdminManager->GetAdminSection(L"system.webServer/security", L"MACHINE/WEBROOT/APPHOST/webSiteName", &spElement);

    This fails with HRESULT '-2147024894', which is hr 0x80070002 The system cannot find the file specified.  Does anybody have any ideas?

     I also tried passing in L"MACHINE/WEBROOT/APPHOST" as a parameter value, and setting overrideMode="Allow" everwhere I thought it could help.  I'm pretty stuck right now.


    Monday, January 8, 2007 7:01 PM
  • User511787461 posted

    There is no section named system.webServer/security - it is a section-group, there are sections named system.webServer/security/authentication/anonymousAuthentication etc

    It is not easy to tell from just looking at the config file what is a section vs a section-group vs an element inside a section - to figure that out, look at the *schema.xml files in %windir%\system32\inetsrv\config\schema\ - in particular at IIS_schema.xml in this case.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Monday, January 8, 2007 7:32 PM
  • User-1202834629 posted
    Great, that worked...thanks again for responding so quickly!
    Monday, January 8, 2007 7:51 PM