Reputation: 3345
I have my asp.net web site. This web site is part of another big application that has its own web.config
. Is it possible to force my web site use this web.config
?
For example, root application with web.config
:
C:\RootApp\web.config
And nested web site:
C:\RootApp\SomeFolder\NestedWebSite
I want NestedWebSite
to use root web.config
.
Note: NestedWebSite
is complete ASP.NET WebSite
Upvotes: 1
Views: 58
Reputation: 3976
You should take a look how ASP.NET Configuration File Hierarchy and Inheritance works. More specifically the Scope of Configuration Settings section.
Basically it cascade (like Belogix
pointed out) the configurations follow how the virtual directory is configured.
WebSiteRootApp
---->AnotherNestedWebSite
-------->EvenMoreNestedWebSite
---->NestedWebSite
In this example the NestedWebSite
will inherit all config above (according the links I provided). But in this example I want to point that it will inherit your WebSiteRootApp
config.
In the EvenMoreNestedWebSite
example it will inherit its "father" and "grampa" too, in this case AnotherNestedWebSite
and WebSiteRootApp
.
Some configurations maybe you will not want to inherit so you can avoid this with this example:
<connectionStrings>
<clear/>
<add name="connectionString" value="sample value"/>
</connectionStrings>
In the above example I can specify that EvenMoreNestedWebSite
needs to forget all configurations in that section it inherit and use just the one provided.
Upvotes: 2