By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,781 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,781 IT Pros & Developers. It's quick & easy.

blackbelt web.config question - level 400

P: n/a
I use web.config files in many directories, and my aspx files can access the
AppSettings.
If I have a subdirectory Foo with an aspx, and Foo has a local web.config
that defines an AppSetting. My aspx in the Foo directory can properly
access this local AppSetting. I understand that web.config files are
cumulative as you go deep into the directory structure.

Here is my situation.

I have an aspx in the root of my application. I have a UserControls
subdirectory. I have a web.config file in the UserControls directory. In
my root-level aspx file, I register and user my user control in the
subdirectory. My user control's code looks for an AppSetting in the
/UserControls/web.config file, but it cannot find that configuration
information.

If the web.config AppSettings are in the web.config at the root of the
application, all is well, or if the aspx that uses the user control is
actually in the /UserControls/ directory, all is well.

So, I haven't been able to use AppSettings from a web.config file that is
local to the user control but not local (or upstream) to the aspx. Is this
by design and undoable, or is there a workaround?

Best regards,
Jeffrey Palermo
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
there is only one web.config per .net application (vdir). web.config files
in sub directories are ignored, unless your code reads the xml files
directly. you can turn a subdirectory into a seperate application with its
own web config by making it a vdir.

-- bruce (sqlwork.com)

"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
I use web.config files in many directories, and my aspx files can access the AppSettings.
If I have a subdirectory Foo with an aspx, and Foo has a local web.config
that defines an AppSetting. My aspx in the Foo directory can properly
access this local AppSetting. I understand that web.config files are
cumulative as you go deep into the directory structure.

Here is my situation.

I have an aspx in the root of my application. I have a UserControls
subdirectory. I have a web.config file in the UserControls directory. In
my root-level aspx file, I register and user my user control in the
subdirectory. My user control's code looks for an AppSetting in the
/UserControls/web.config file, but it cannot find that configuration
information.

If the web.config AppSettings are in the web.config at the root of the
application, all is well, or if the aspx that uses the user control is
actually in the /UserControls/ directory, all is well.

So, I haven't been able to use AppSettings from a web.config file that is
local to the user control but not local (or upstream) to the aspx. Is this by design and undoable, or is there a workaround?

Best regards,
Jeffrey Palermo

Nov 18 '05 #2

P: n/a
Jeffrey,
The path used to fetch the web.config is based on Request.FilePath - in
other words the path of the page being executed and not the path of the user
control. Looking at the dissassembled code, I was able to confirm this,
briefly:

System.Web.Configuration.HttpConfigurationSystemBa se actually implemenets
the GetConfig()
It calls the HttpContext's GetConfig() method
HttpContext.GetConfig calls HttpContext.GetCompleteConfig
this in turn calls GetCompleteConfigRecords and passes
HttpContext.ConfigPath
HttpContext.ConfigPath is simply a property which wraps around
HttpContext.Current.Request.FilePath

eventually down the road, the file is removed from the ConfigPath and
"web.config" is appended to it.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
I use web.config files in many directories, and my aspx files can access the AppSettings.
If I have a subdirectory Foo with an aspx, and Foo has a local web.config
that defines an AppSetting. My aspx in the Foo directory can properly
access this local AppSetting. I understand that web.config files are
cumulative as you go deep into the directory structure.

Here is my situation.

I have an aspx in the root of my application. I have a UserControls
subdirectory. I have a web.config file in the UserControls directory. In
my root-level aspx file, I register and user my user control in the
subdirectory. My user control's code looks for an AppSetting in the
/UserControls/web.config file, but it cannot find that configuration
information.

If the web.config AppSettings are in the web.config at the root of the
application, all is well, or if the aspx that uses the user control is
actually in the /UserControls/ directory, all is well.

So, I haven't been able to use AppSettings from a web.config file that is
local to the user control but not local (or upstream) to the aspx. Is this by design and undoable, or is there a workaround?

Best regards,
Jeffrey Palermo

Nov 18 '05 #3

P: n/a
Bruce, children web.config are valid, you might wish to read:

http://msdn.microsoft.com/library/de...chitecture.asp

or
http://support.microsoft.com/default...;en-us;307626&

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"bruce barker" <no***********@safeco.com> wrote in message
news:OH**************@TK2MSFTNGP15.phx.gbl...
there is only one web.config per .net application (vdir). web.config files
in sub directories are ignored, unless your code reads the xml files
directly. you can turn a subdirectory into a seperate application with its
own web config by making it a vdir.

-- bruce (sqlwork.com)

"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
I use web.config files in many directories, and my aspx files can access

the
AppSettings.
If I have a subdirectory Foo with an aspx, and Foo has a local web.config that defines an AppSetting. My aspx in the Foo directory can properly
access this local AppSetting. I understand that web.config files are
cumulative as you go deep into the directory structure.

Here is my situation.

I have an aspx in the root of my application. I have a UserControls
subdirectory. I have a web.config file in the UserControls directory. In my root-level aspx file, I register and user my user control in the
subdirectory. My user control's code looks for an AppSetting in the
/UserControls/web.config file, but it cannot find that configuration
information.

If the web.config AppSettings are in the web.config at the root of the
application, all is well, or if the aspx that uses the user control is
actually in the /UserControls/ directory, all is well.

So, I haven't been able to use AppSettings from a web.config file that is local to the user control but not local (or upstream) to the aspx. Is

this
by design and undoable, or is there a workaround?

Best regards,
Jeffrey Palermo


Nov 18 '05 #4

P: n/a
Karl,
That's the behavior I experienced, but thank you for confirming it
for me. The .Net docs aren't that in-depth.

In light of this, I'm going to change the web.config file that is
local to my user control to a normal .xml file that I'll read in
explicitly with my user control's code. I'll make a static config
class that'll hold the config info in application scope.

Thanks Karl.

Best regards,
Jeffrey Palermo

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:<#X*************@tk2msftngp13.phx.gbl>...
Jeffrey,
The path used to fetch the web.config is based on Request.FilePath - in
other words the path of the page being executed and not the path of the user
control. Looking at the dissassembled code, I was able to confirm this,
briefly:

System.Web.Configuration.HttpConfigurationSystemBa se actually implemenets
the GetConfig()
It calls the HttpContext's GetConfig() method
HttpContext.GetConfig calls HttpContext.GetCompleteConfig
this in turn calls GetCompleteConfigRecords and passes
HttpContext.ConfigPath
HttpContext.ConfigPath is simply a property which wraps around
HttpContext.Current.Request.FilePath

eventually down the road, the file is removed from the ConfigPath and
"web.config" is appended to it.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
I use web.config files in many directories, and my aspx files can access

the
AppSettings.
If I have a subdirectory Foo with an aspx, and Foo has a local web.config
that defines an AppSetting. My aspx in the Foo directory can properly
access this local AppSetting. I understand that web.config files are
cumulative as you go deep into the directory structure.

Here is my situation.

I have an aspx in the root of my application. I have a UserControls
subdirectory. I have a web.config file in the UserControls directory. In
my root-level aspx file, I register and user my user control in the
subdirectory. My user control's code looks for an AppSetting in the
/UserControls/web.config file, but it cannot find that configuration
information.

If the web.config AppSettings are in the web.config at the root of the
application, all is well, or if the aspx that uses the user control is
actually in the /UserControls/ directory, all is well.

So, I haven't been able to use AppSettings from a web.config file that is
local to the user control but not local (or upstream) to the aspx. Is

this
by design and undoable, or is there a workaround?

Best regards,
Jeffrey Palermo

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.