473,395 Members | 2,796 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,395 software developers and data experts.

How to tell if web.config item is/is not inherited

Probably a very basic questions here:
When using code to look at a web.config item, how can I tell if the value
is/is not inherited? I have some common code that needs to iterate through
settings like appsettings and connectionstrings but I only want to look at
settings for the current web app: I would like to ignore a value if it
comes from a web.config up the folder heirarchy....it does not exist in the
current web apps web.config. And I do not want a developer to have to use a
Remove element to exclude the value just so the code can work.

Using .Net 2

Thanks

Brad
Mar 26 '07 #1
3 1261
Hi Brad,

Based on my understanding, you're using
WebConfigurationManager.OpenConfiguration() to read from web.config, you
noticed that appSettings and connectionStrings in the Configuration object
contain both settings inherited from parent web.config and settings in
itself. You want to know is it possible to differentiate them or only get
those settings in itself. Please correct me if I've misunderstood anything.

I've done some researching and looked into the WebConfigurationManager's
source code using Reflector (http://www.aisto.com/roeder/dotnet/),
unfortunately it seems not possible to only return a Configuration object
with settings from the web.config itself in current .NET framework version.
Your objective is a reasonable one and we're sorry for the inconvenience
caused. I will make sure your feedback gets forwarded to product team.

For now, I'm afraid you will have to read the web.config yourself to
determine which appsettings or connectionstrings are in it. I can give
further suggestion if you could elaborate more about your objective. Thanks.

In the meanwhile, you're also welcome to submit your feedback at
http://connect.microsoft.com/Main/co...ContentID=2220 which
is monitored by our product team directly. Thanks again for your feedback.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 27 '07 #2
Thank you for the information. I can just examine the web.config as an
xmldocument.

Brad

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:gP**************@TK2MSFTNGHUB02.phx.gbl...
Hi Brad,

Based on my understanding, you're using
WebConfigurationManager.OpenConfiguration() to read from web.config, you
noticed that appSettings and connectionStrings in the Configuration object
contain both settings inherited from parent web.config and settings in
itself. You want to know is it possible to differentiate them or only get
those settings in itself. Please correct me if I've misunderstood
anything.

I've done some researching and looked into the WebConfigurationManager's
source code using Reflector (http://www.aisto.com/roeder/dotnet/),
unfortunately it seems not possible to only return a Configuration object
with settings from the web.config itself in current .NET framework
version.
Your objective is a reasonable one and we're sorry for the inconvenience
caused. I will make sure your feedback gets forwarded to product team.

For now, I'm afraid you will have to read the web.config yourself to
determine which appsettings or connectionstrings are in it. I can give
further suggestion if you could elaborate more about your objective.
Thanks.

In the meanwhile, you're also welcome to submit your feedback at
http://connect.microsoft.com/Main/co...ContentID=2220
which
is monitored by our product team directly. Thanks again for your feedback.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Mar 27 '07 #3
Hi Brad,

Thanks for your understanding. Please feel free to let me know if there's
anything else I can help.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Maxim Khesin | last post by:
I want to have a config file with my python proggie, satisfying the following requirements: 1) support key->(value, default) 2) simple and intuitive to read and edit 3) easyly readable into a...
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...
6
by: Jose Perez | last post by:
Dear All, We are experiencing a problem with web.config and the fact that it's settings are being "inherited" other applications. Our default website is configured to run "MyApplication1". The...
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: stand__sure | last post by:
I had occasion tonight to write an installer class that changed something in a config file tonight (I had never had a need to do it, but happened upon a "How To" article that explained it in terms...
12
by: Ben | last post by:
I have a group of settings that I'd like to have inherited by multiple sites. I'm trying this, but it's not working. wwwroot\group\web.config wwwroot\group\site1\web.config...
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...
6
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
I have configuration data for a web application stored in a file galleryserverpro.config located in a config folder off the root application. Web.config references this file like this:...
5
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a app that uses several membership/role providers. I can list these Providers with the code: Dim rootWebConfig1 As Configuration rootWebConfig1 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.