473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

blackbelt web.config question - level 400

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
4 2200
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Richard | last post by:
Hi, I'm having trouble setting up a config file based trace switch & listener. I added an application config file to my console based C# program using the "Add New Application Config File" button...
5
by: BPearson | last post by:
Hello I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to...
9
by: Benny Ng | last post by:
Hi,all, How to let the sub-directory to avoid the authentication control from Root's webconfig? I heard that we can add a new web.config to the sub-directory. And then we can slove the problem....
5
by: Mart | last post by:
Hi everybody, I plan to have a LOT of SQL string in my app. So I need your advice for this. Is it a good idea to store all my SQL string in the app.config file? For a maintenance point of...
2
by: Max Metral | last post by:
I'm trying to set the default behavior of customErrors in the machine.config. The documentation seems to suggest this should work, but it doesn't seem to work for me. On my development machine, I...
10
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a...
5
by: alf | last post by:
Hi folks, I'm trying to read a web.config section using RoleManagerSection settings = (RoleManagerSection)System.Configuration.ConfigurationManager.GetSection("system.web/roleManager"); and I...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
5
by: mmcd79 | last post by:
I built a VB.net application that makes use of a machine level DB connection string setting, and a user level starting location setting. The machine level setting and the default user based...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.