Multiple web.config files?

Discussion in 'ASP.NET 2.0' started by stellaisev1, Jan 17, 2006.

  1. How many web.config files can there be?

    I have one in my root directory and have another in a sub-application. The sub-application appears to be using the one in the root. Why would this be?

    Nick
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    web.config inherits from the parent directory. it doesn't start fresh from the app root.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. So if that's the case, how do I reset a value? For example in my top-level web.config I have <page styleSheetTheme="Black"/>. I don't wan't the sub-application to inherit this.

    Nick
     
  4. Bruce

    Bruce DiscountASP.NET Staff

  5. Maybe I didn't understand the way you were stating it Bruce, but from MSDN:

    Multiple configuration files, all named Web.config, can appear in multiple directories on an ASP.NET Web application server. Each Web.config file applies configuration settings to its own directory and all child directories below it. Configuration files in child directories can supply configuration information in addition to that inherited from parent directories, and the child directory configuration settings can override or modify settings defined in parent directories. The root configuration file named systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Machine.config provides ASP.NET configuration settings for the entire Web server.

    So a child directory web.config will override a parent directory web.config setting, just as a the root level web.config will override the Machine.config settings (unless specifically stated in the Machine.config that is cannot be overridden).

    You can override the root level or parent level web.config setting by ensuring you have the <page styleSheetTheme=''/> element. If it doesnt exist in the child web.config, it is inheriting the setting from it's parent.

    -Jeff
     
  6. Bruce

    Bruce DiscountASP.NET Staff

    Some element (eg. assembly) needs to be specifically removed.

    I guess some other element will be overwritten.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. Thanks for all your answers. Adding <pages styleSheetTheme=""/> worked fine. styleSheetTheme might not be the correct name for the attribute but I don't have the source handy so I can't check. Was something like that.

    Thanks once again

    Nick
     

Share This Page