problem with web.config

J

Joseph

I have 2 web applications, one called myappA put under the website root
(http://localhost) and one called myappB under a virtual directory
(http://localhost/myappB) and they are mapped to different physical
directory (c:\\inetput\wwwroot\myappA and c:\\inetput\wwwroot\myappB). I
have a key defined in the web.config for myappB and the same key is not
defined in myappA. When I run myappB it is complaining the key is not found.
If I put the same key in the web.config for myappA then no error is
reported. Why did myappB check the web.config in myappA and just ignore the
key in its web.config? They are 2 different applications in 2 different
virtual directories. I believe the web.config of these 2 applications are
independent to each other. Is it right? Or my assumption is wrong if one of
the applications is put under the website root?

thanks,
Joseph
 
S

Steven Cheng[MSFT]

Hi Joseph,

From your description, your sub asp.net web application will search keys
in the parent applicaiton's web.config rather than its own web.config, yes?

based on your scenario, I've also done a simple test on my side, I put a
web.config in the wwwroot and add a "key" in the <appSettings> , then in
the sub web application's web.config, I also put the same "key". When
running the application, it seems that the sub application will always use
the one in its own web.config. In other word, the sub web.config will
override the parent one's setting. But my test is based on the IIS's defaut
configuration, the root applicaiotn is mapped to the "inetput\wwwroot".

I think you can first restart the IIS and do a same simple test as I
mentioed to see whether the result is the same. Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
J

Joseph

I have the same result as you have done, if I put the same key in both
applications. However, if I put the key only in the sub application but not
in the root application, getting the key by the sub application resulted in
an error. It was trying to read the web.config from the root application,
which the key is not defined in its web.config. My root application is
hosted under inetpub\wwwroot. I expect the sub application would use the key
defined in its own web.config.

Joseph
 
S

Steven Cheng[MSFT]

Hi Joseph,

I've also tried the things you mentioned(parent web.config hasn't key ,
child web.config has). But my test seems still ok for the sub application
to get the key in its own web.config file. And since this is a quite normal
behavior, I suspect that whether there is anything incorrect with the
server or? Have you tried the same test on some other machines(or create a
new site do the same test)?


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

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

Top