|
-
Feb 6th, 2003, 02:51 PM
#1
Thread Starter
Hyperactive Member
Understanding Web.Config *RESOLVED*
I'm using the config file for storing some application-wide settings. So I have an entry like this in web.config:
<appSettings>
  <add key="A" value="whatever" />
</appSettings>
I then grab the value for a key like like this:
ConfigurationSettings.AppSettings("A")
Nothing special so far...
But what I've also got is a web app nested within another web app, so it kind of looks like:
Parent Virtual Directory
Web.Config (Key="A"...)
Parent.aspx
Child Virtual Directory
Web.Config (Key="B"...)
Child.aspx
The behavior I'm seeing is the Child code can retreive a config setting defined at the parent level. In other words in the above example, child.aspx can make 2 calls :
ConfigurationSettings.AppSettings("A")
ConfigurationSettings.AppSettings("B")
and get a value for each, but each value is coming from a different config file.
Is this legitimate stuff? Understanding better will really help me out. Thanks!
Last edited by fungi; Feb 10th, 2003 at 11:19 AM.
-
Feb 8th, 2003, 01:12 AM
#2
Fanatic Member
well, this is how it works...
if you don't have a web.config file in a subfolder of the folder above it, the subfolder will use the web.config file from the folder that the subfolder is in...
example...
VB Code:
wwwroot
-MySite
Web.Config
-MySubFolder
Web.Config
If -MySubFolder didn't contain a web.config, all settings from the wwwroot/MySite/Web.Config file would apply to all files in MySubFolder....
and even if you do have a Web.Config file in MySubFolder, all settings that are specified in wwwroot/MySite/Web.Config apply to MySubFolder, unless the Web.Config file in MySubFolder specifies otherwise...
it's kind of like inheritable permissions in winnt/2k/xp... it assumes all the settings of the parent directory's config file unless the setting is specific in the owner's own config file...
that is why your Key A and Key B both work.... try putting the A Key, and a different value for Key A in the child directorie's config file... it will return that value...
i hope that's somewhat clear.. it's late and it's hard for me to get my point across in words
-
Feb 10th, 2003, 11:18 AM
#3
Thread Starter
Hyperactive Member
Thanks redth, you clarified nicely just what I was suspecting. Any ideas on where I'd look to find this information discussed officially like in MSDN?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|