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

Inherited web.config ASP.NET 2.0

Ben
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
wwwroot\group\site2\web.config

Where site1 & site2 are applications.

I have tried making group a subweb, an application and a subweb and
application. No matter what, site1 and site2 don't see the settings from
the group\web.config.

The funny thing is if I make my changes to wwwroot\web.config then site1 &
site2 see the changes. There is of course a catch, the changes are 2.0 and
the server is still running 1.1 sites so the 2.0 settings in the
wwwroot\web.config break all of the 1.1 sites :(

I'm open to any suggestions, thanks!

Ben
Jul 24 '06 #1
12 4713
Hello Ben,

Welcome to the ASP.NET newsgroup.

From your description, you have hosted multiple ASP.NET 2.0 and 1.1 web
applications under a IIS website. And those ASP.NET 2.0 web applications
are under the same parent directory in the IIS virtual path. currently
you're trying to store some shared configuration info in the web.config
file within the parent directory of those ASP.NET 2.0 applications so that
they can automatically inherits the setting from them, correct?

Based on my understanding, such inheritance is naturally supported in
ASP.NET application(both 1.1 and 2.0). And the following MSDN document
describe the general rules of such configuration inheritance:

#ASP.NET Configuration File Hierarchy and Inheritance
http://msdn2.microsoft.com/en-us/library/ms178685.aspx

For your scenario, I think the problem may caused by the following things:

1. How are all the directories(from the IIS site root to the sub
application) created, through a physical sub directory or a mapped external
physical path? e.g. in your case, the complete path is "wwwroot\group\siteX"

Then, is the "group" directory a physical sub directory of "wwwroot"(site
root)? I've performed some local tests, and if the "group" folder is a
physical sub directory(not necessarily an application virtual directory),
the web.config setting in it will be inherited by any sub ASP.NET
applications under it(not matter through physical sub directory or a mapped
virtual directory poinetd to an external physical path).

2. What's the configuration sections are you going to share in the parent
web.config file? My local test use the "<connectionStringssection as the
one to be inherited and it works well. Are you going to share the same
setting or any paricular configuration setting?

Anyway, please feel free to let me know if there is anything I've missed or
if there is any particular concerns in your scenario.

Looking forward to your update.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

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.


Jul 25 '06 #2
Hello Ben,

How are you doing on this issue? Have you got any progress or still meet
any difficulties on this issue? If there is anything else we can help,
please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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

Jul 27 '06 #3
Ben
Steven,

Thanks for your reply. I haven't had any luck with this. The only way the
settings (connection strings) are inherited is if they are in the root of
the site.

inetpub\wwwroot\web.config - main
inetpub\wwwroot\group1\web.config - shared
inetpub\wwwroot\group1\site1
inetpub\wwwroot\group1\site2
inetpub\wwwroot\group1\site3

With the file structure above, if I put a connection string in the main
config file, site1, site2 and site3 see the connection string. If I remove
the connection string from the main config and place it in the shared
config, none of the sites see the setting.

Is what I'm doing something that should be working? I thought so, but it
isn't.

Thanks,
Ben

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:qu**************@TK2MSFTNGXA01.phx.gbl...
Hello Ben,

How are you doing on this issue? Have you got any progress or still meet
any difficulties on this issue? If there is anything else we can help,
please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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

Aug 9 '06 #4
re:
With the file structure above, if I put a connection string in the main config file, site1, site2
and site3 see the connection string. If I remove the connection string from the main config and
place it in the shared config, none of the sites see the setting.
Is what I'm doing something that should be working?
No.

Root web.config settings are inherited, unless they are overturned
by a different setting in a web.config down the directory tree.

If you place a setting in inetpub\wwwroot\group1\web.config,
the setting will be local to the \group1 directory, but the
subdirectories below it will inherit from the root directory.

The reason for that is that \group1 is not an application.

If you want to have different settings in subdirectories, you must place
them in a web.config in the directories the different settings apply to.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Ben" <be*****@newsgroups.nospamwrote in message news:26***************************@FUSE.NET...
Steven,

Thanks for your reply. I haven't had any luck with this. The only way the settings (connection
strings) are inherited is if they are in the root of the site.

inetpub\wwwroot\web.config - main
inetpub\wwwroot\group1\web.config - shared
inetpub\wwwroot\group1\site1
inetpub\wwwroot\group1\site2
inetpub\wwwroot\group1\site3

With the file structure above, if I put a connection string in the main config file, site1, site2
and site3 see the connection string. If I remove the connection string from the main config and
place it in the shared config, none of the sites see the setting.

Is what I'm doing something that should be working? I thought so, but it isn't.

Thanks,
Ben

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:qu**************@TK2MSFTNGXA01.phx.gbl...
>Hello Ben,

How are you doing on this issue? Have you got any progress or still meet
any difficulties on this issue? If there is anything else we can help,
please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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


Aug 9 '06 #5
re:
Juan, did you get the same results as Ben?
Hi, Steven.

My results are similar to yours for unconfigured directories down the tree.

I assumed that "inetpub\wwwroot\group1\site1" and the other two sites
( site2 and site3 ) were configured as separate applications.

Hence, the comment that they wouldn't inherit from /group1.

I stand by :
"Root web.config settings are inherited, unless they are overturned
by a different setting in a web.config down the directory tree."

And regret any confusion stemming from :
"If you place a setting in inetpub\wwwroot\group1\web.config,
the setting will be local to the \group1 directory, but the
subdirectories below it will inherit from the root directory."

What I meant to write was :
"If you place a setting in inetpub\wwwroot\group1\web.config,
the setting will be local to the \group1 directory, but the
subdirectories below it will inherit from their application's root directory."
( working on the assumption that the subdirectories are separate apps,
therefore they each have separate application roots, so they would *not*
inherit from a directory placed higher than them in the directory tree)


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:c3**************@TK2MSFTNGXA01.phx.gbl...
Hi Ben,

Thanks for the reply and thanks for Juan's inputs.

I don't think there is any difference between your test site and my local
test site's structure.

Juan, did you get the same results as Ben? I've tested this on my local
environment and web.config file inheritance does work as long as the
web.config is put in the parent folder that is in the folder path (to the
leaf application node).

I've attached a screenshot of my local test site's folder structure (in the
default IIS site):

The directory sturecture is

Default Site/
ASPNET/
V2/
WebSites/
.....web applications

Except the "Root Default Site" and the leaf web applications, all the other
directory in the hierarchy are normal virtual directory. I've put
web.config files(only contains some <appSettingkeys) in the following
directories:

*Default Site(root)

*V2

*WebSites

And in the web applications under "Websites", I can use the following code
to get all the appSetting keys defined in all the web.config files above:

=====================
protected void Page_Load(object sender, EventArgs e)
{
foreach (string key in WebConfigurationManager.AppSettings.Keys)
{
Response.Write("<br/>"+ key + ": " +
WebConfigurationManager.AppSettings[key]);
}
}
=====================

#Note, I haven't used any external mapped phyiscal directory for the above
virtual directories, they're all under the inetput/wwwroot. So the physical
direcotry structure is as below:

wwwroot\ASPNET\V2\WebSites\xxxweb applications dirs...

Is there anything different from your test applications? I'm using windows
2003 server/IIS6, ASP.NET 2.0

Please feel free to let me know if there is anything else you wonder or can
help you on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 10 '06 #6
re:
Do you mean if the sub directories are configured as "application", they
won't inherit the web.config setting from their parent (no matter they're
physical sub dir or the parent virtual dir or not)?
Steven,

are you telling me that in this physical/virtual directory structure :

c:\inetpub\wwwroot -not an application
c:\inetpub\wwwroot\group1 - not an application
c:\inetpub\wwwroot\group1\site1 - IIS Application
c:\inetpub\wwwroot\group1\site2 - IIS Application
c:\inetpub\wwwroot\group1\site3 - IIS Application

....that site1, site2 and site3 will inherit from c:\inetpub\wwwroot 's
or c:\inetpub\wwwroot\group1 's web.config ?

*That* is the structure I was commenting on.

I *never* configure wwwroot as an application,
precisely because I don't want to run the risk of inheritance ambiguities.

I have always thought that Application roots are the topmost level
for web.config inheritance boundaries, unless the IIS Application is nested,
in which case, yes, the Application will inherit from its parent Application. .

Maybe I'm not understanding something about the scenario ?


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:7N**************@TK2MSFTNGXA01.phx.gbl...
Hi Juan,

Thanks for your effort.

As for your following comments:

=====================
"If you place a setting in inetpub\wwwroot\group1\web.config,
the setting will be local to the \group1 directory, but the
subdirectories below it will inherit from their application's root
directory."
( working on the assumption that the subdirectories are separate apps,
therefore they each have separate application roots, so they would *not*
inherit from a directory placed higher than them in the directory tree)
======================

Do you mean if the sub directories are configured as "application", they
won't inherit the web.config setting from their parent (no matter they're
physical sub dir or the parent virtual dir or not)?

Actually, you can see(in the screenshot I attached) that those leaf
applications directories( "DemoWebsite", "IISTestSite", "NewTestSite"....)
are all configured as single application themselves. However, they can
still get the settings from the web.config files in the super path(in V2,
in ASPNET in Websites super parent dirs). The page in those applications
are accesed through the following style url.

http://localhost/ASPNET/V2/WebSites/...e/Default.aspx

In addition, I've also tested through a linked sub application (its
physical directory is outside the parent application/virtual dir 's
physical path, see the "linkedsubweb" in my new attached screenshot), it
can also get the inherited values from parent web.configs.

Therefore, I still think web.config's inheritance in a IIS virtual
directory tree is certainly supported.

So far I'm still wondering what's the exact directory structure in IIS and
physical disk in Ben's test environment.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 10 '06 #7
Thanks for your quick reply Juan,

Yes, on my test server, the wwwroot is configured as "application" , and
this is the default setting after it is installed. Also, I've tested
removing the application(let it be a normal root virtual folder), and the
same result, sub web applications can still inhertis settings from all the
web.config files in the up level directorys(follow the virtual directory
tree).

As for the following statement;
===========================
I have always thought that Application roots are the topmost level
for web.config inheritance boundaries, unless the IIS Application is nested,
in which case, yes, the Application will inherit from its parent
Application. .
==========================

I think for those application specific states such as SessionState,
Appilcation State, this the case, however, web.config setting will inherit
up level web.configs in super directories(no matter application or not)
based on my understanding and testing.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 10 '06 #8
Thanks for that heads-up, Steven.

I had been laboring under a mistaken assumption.

I just tested, changing the culture and uiCulture in the wwwroot and,
in spite of a test directory being configured as an application,
the culture setting *was* inherited from the root.

Thanks again.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:n4**************@TK2MSFTNGXA01.phx.gbl...
Thanks for your quick reply Juan,

Yes, on my test server, the wwwroot is configured as "application" , and
this is the default setting after it is installed. Also, I've tested
removing the application(let it be a normal root virtual folder), and the
same result, sub web applications can still inhertis settings from all the
web.config files in the up level directorys(follow the virtual directory
tree).

As for the following statement;
===========================
I have always thought that Application roots are the topmost level
for web.config inheritance boundaries, unless the IIS Application is nested,
in which case, yes, the Application will inherit from its parent
Application. .
==========================

I think for those application specific states such as SessionState,
Appilcation State, this the case, however, web.config setting will inherit
up level web.configs in super directories(no matter application or not)
based on my understanding and testing.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 10 '06 #9
Thanks Juan for your time,

So curerntly I'm still wondering the actual scenario of Ben's deployment
site and will wait for any further feedback. I think it important to make
this issue clear so that other guys won't suffer the problem any more.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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

Aug 11 '06 #10
re:
So currently I'm still wondering the actual scenario of Ben's deployment
site and will wait for any further feedback.
We haven't heard from him for 3 days now.
My curiosity is getting the best of me.

;-)

re:
I think it important to make this issue clear so that other guys won't suffer the problem any
more.
Agreed!

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:ur**************@TK2MSFTNGXA01.phx.gbl...
Thanks Juan for your time,

So curerntly I'm still wondering the actual scenario of Ben's deployment
site and will wait for any further feedback. I think it important to make
this issue clear so that other guys won't suffer the problem any more.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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

Aug 11 '06 #11
Ben
I apologize for my delayed response. My news reader wasn't showing any
activity in this thread, so I thought it ended with Juan saying it couldn't
be done. My directory structure is as follows...

c:\inetpub\wwwroot\web.config
c:\inetpub\wwwroot\aspnet20\web.config
c:\inetpub\wwwroot\aspnet20\site4\
c:\inetpub\wwwroot\aspnet20\site5\
c:\inetpub\wwwroot\aspnet20\site6\
c:\inetpub\wwwroot\aspnet11\site1\
c:\inetpub\wwwroot\aspnet11\site2\
c:\inetpub\wwwroot\aspnet11\site3\

Where each site* is configured as an application and virtual directory using
/site* as its' alias.

What we had been doing was storing shared configuration information in
c:\inetput\wwwroot\web.config. This allowed us to place a setting in the
root web.config for all of the 1.1 sites on the server to see. This was
working great, then we started working with the 2.0 sites. Some of the
configuration options from 2.0 cause web.config validation exceptions when a
1.1 site attempts to inherit the setting. I was hoping to be able to use an
inherited web.config file in the c:\inetpub\wwwroot\aspnet20 folder for
configuration inheritance down to any sub folders containing applications.
This just doesn't seem to be working out though. One of the main issues
here is connection string management. Our environment contains a
development server, staging server and a live server. Through the use of
inherited config files, we can make sure that dev always traces, shows
errors and points to the dev sql server while staging never traces or shows
errors and uses the staging database. Before inherited configuration files
people were publishing to staging, forgetting to update their config file to
change database, trace or custom error attributes and without knowing it
sites on staging were using the dev db etc.

Right now, we are doing something I don't like at all, we are placing shared
2.0 configuration information in the 2.0 machine.config...

Thanks,
Ben

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e0**************@TK2MSFTNGP04.phx.gbl...
re:
>So currently I'm still wondering the actual scenario of Ben's deployment
site and will wait for any further feedback.

We haven't heard from him for 3 days now.
My curiosity is getting the best of me.

;-)

re:
>I think it important to make this issue clear so that other guys won't
suffer the problem any more.

Agreed!

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:ur**************@TK2MSFTNGXA01.phx.gbl...
>Thanks Juan for your time,

So curerntly I'm still wondering the actual scenario of Ben's deployment
site and will wait for any further feedback. I think it important to make
this issue clear so that other guys won't suffer the problem any more.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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


Aug 14 '06 #12
Hi Ben,

Glad to hear from you.

I'm sorry to hear that you haven't got it work. Yes, I understand your
plan, since connectionStrings section is specific to v 2.0 only, you would
like to put it in a shared web.config under the root virtual directory of
the ASP.NET 2.0 applications and avoid the setting be inherited by 1.1
applciations.

My local test does follow the scenario you describs and that inheritance
works. I think there must still have some difference in our test
environment.

Anyway, if you would like to perform further investigation on this, please
feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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

Aug 15 '06 #13

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

Similar topics

9
by: Codex Twin | last post by:
Hi I have a common model for a Data Access Layer scenario. I have an abstract base class, called DalBase which contains a list of abstract methods. Lets call them: public abstract void Shine();...
1
by: plaztik via DotNetMonster.com | last post by:
Hello, My company creates many similar web applications for clients. I was assigned the task of creating a versionable engine for producing these web applications easily and protecting our code....
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....
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
0
by: tomislav.bartolin | last post by:
Hi, I have inherited TaskSettings class from the ApplicationSettingsBase class and are able to get the configuration settings for this class quite nicely in my windows app. Now, if I inherit...
4
by: asad.naeem | last post by:
hi to all this is the problem about inheritence. I have designed a form with some essential controls which are required for every form which will inherited from it. for example i have Button1 on...
0
by: Jay Pondy | last post by:
I added a Company field to the aspNet_Users table and then followed along with the MSDN docs on How to Implement a Custom Membership User by creating my inherited class from the...
3
by: Brad | last post by:
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...
1
by: Zark3 | last post by:
Hello all, I've been given the task of rewriting part of a 1.1 app as a new 2.0 app. I'll have to keep the old directory name so references from the old app will sneakly direct the user straight...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.