When does WCF use app.config or web.config?

╄→гoц情女王★ 提交于 2019-12-10 02:58:23

问题


I am working on a WCF applicaiton. I am very confused about when to use a web.config file and app.config file in WCF client and service. can anyone help me when to use app.config and when to use web.config.


回答1:


Is it hosted with IIS? Web.config. Is it hosted as a standalone service? App.config.

http://msdn.microsoft.com/en-us/library/ms733932.aspx




回答2:


When configuring a service in Visual Studio, use either a Web.config file or an App.config file to specify the settings. The choice of the configuration file name is determined by the hosting environment you choose for the service. If you are using IIS to host your service, use a Web.config file. If you are using any other hosting environment, use an App.config file.




回答3:


Whenever the client or server application starts up, it loads the configurations from the .config files. For example, in WCF, you can configure the bindings and endpoints in the .config file, when the application starts up, it will first analyze the config file and create the endpoints and bindings accordingly.

These config doesn't need to be rebuilt when you change them, so if you want to change the behavior when the application is deployed, I think config file is the best choice.



来源:https://stackoverflow.com/questions/6814082/when-does-wcf-use-app-config-or-web-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!