Multiple web.config files in a virtual directory

R

Raghu

Is it possible to have multiple web.config files in a given virtual
directory in different directories? For example:

http://localhost/myapp (Virtual directory maps to C:\MyApp)
http://localhost/myapp/newFolder (web folder in the above virtual dir maps
to C:\MyApp\NewFolder)

Can I have one web.config file at C:\MyApp and another at
C:\MyApp\NewFolder? When I tried to do this, VS.NET web project (during
debugging) throws an errors saying that something is wrong at the server? So
I compiled the project and tried to bring to navigate to a page in the
browser (without debugging), I still get an error. But when I remove the
web.config file at C:\MyApp\NewFolder, it works fine.

Any help is appreciated.

Thanks.
Raghu/..
 
C

Curt_C [MVP]

yes, but you are limited what can be in the second one... usually thought
its better to have the ONE in the root and use the <location> tags to
explicitely handle things in the subfolders
 
J

John Saunders

Curt_C said:
yes, but you are limited what can be in the second one... usually thought
its better to have the ONE in the root and use the <location> tags to
explicitely handle things in the subfolders

Curt, what are the limitations on the web.config in the subfolder?

The only limitation I'm aware of is an issue with assembly references if the
sub-folder is also an application. If the main web.config uses

<httpModules>
<add name="MyModule" type="MyNamespace.MyModule, MyAssembly" />
</httpModules>

Then the subapplication will be looking for a SubApp\bin\MyAssembly.dll. You
can add a <remove name="MyModule" /> to the sub-web.config, but it's already
too late - ASP.NET will be looking for MyAssembly.dll before it gets around
to processing your <remove>. The workaround is to place a dummy
MyAssembly.dll in SubApp\bin.
 
J

John Saunders

I meant _if_ the sub is flagged as an app. The issue I raised only happens
if the sub is an app.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top