1
votes

From an existing WebApplication I use to make calls to WCF services. Proxies for these services was created using Add Service Reference menu. Thus generating >> Web.config in this project.

I have added another class library project to the solution. This project also adds reference to the service. Thus generating >> App.Config file in this project.

I understand, in an N-Tier application, we should have common gateway to the service. Just out of curiosity I would like to know -

For WCF calls originated in WebApp, propagated to class library which config file (App/Web) would be referred for locating client endpoint configurations ?

2
If it is a web app that is using the class library, then the web.config file will be used by both the web code, and the library code. However, you can reference other config files to be included in you web.config. I do know how off the top of my head thoughmusefan

2 Answers

1
votes

The web.config file will be used for locating the service.

The reason is because in this case, the app domain belongs to the web app, not the class library, and the default config file for this app domain is the web.config.

0
votes

@musefan is correct. It is the web.config that is used.

If you want to, you can split some confuguration sections into seperate files and reference them from the main web.config. You might want to do this so you can maintain the WCF client and server config in a single place to ensure they are consistent.

foe example, if you want to seperate out the <client> section, you would do this:

<client configSource="client.xml" />

Where client.xml is a file containing the relevant client config information.

This blog post tells you how to do it in a bit more detail.

http://blog.andreloker.de/post/2008/06/keep-your-config-clean-with-external-config-files.aspx