简体   繁体   English

WCF端点是保留在app.config还是web.config中?

[英]Are the WCF Endpoints kept in the app.config or the web.config?

When I create a WCF Service Library, an app.config is generated for me where I put the end points. 当我创建WCF服务库时,会为我生成一个app.config,用于放置端点。 Then if I create a website and reference the WCF Service Library, it creates a web.config file where I can specify the end points. 然后,如果我创建一个网站并引用WCF服务库,它会创建一个web.config文件,我可以在其中指定端点。 Do I put the end points in the app.config or web.config or do they have to be in both? 我是否将端点放在app.config或web.config中,或者它们是否必须同时存在?

Essentially, it's Web.config if you're hosting the services in IIS, app.config if you're self hosting. 基本上,它是Web.config如果您在IIS中托管服务, app.config如果您是自托管。 So it sounds like you want to put them in the web.config . 所以听起来你想把它们放在web.config

Full details can be found here where MSDN says: 完整的详细信息可以在这里找到MSDN说:

When configuring a service in Visual Studio, use either a Web.config file or an App.config file to specify the settings. 在Visual Studio中配置服务时,请使用Web.config文件或App.config文件来指定设置。 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. 如果您使用IIS来托管服务,请使用Web.config文件。 If you are using any other hosting environment, use an App.config file. 如果您使用的是任何其他托管环境,请使用App.config文件。

In Visual Studio, the file named App.config is used to create the final configuration file. 在Visual Studio中,名为App.config的文件用于创建最终配置文件。 The final name actually used for the configuration depends on the assembly name. 实际用于配置的最终名称取决于程序集名称。 For example, an assembly named "Cohowinery.exe" has a final configuration file name of "Cohowinery.exe.config". 例如,名为“Cohowinery.exe”的程序集的最终配置文件名为“Cohowinery.exe.config”。 However, you only need to modify the App.config file. 但是,您只需要修改App.config文件。 Changes made to that file are automatically made to the final application configuration file at compile time. 在编译时,对该文件所做的更改将自动发送到最终的应用程序配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于配置WCF的web.config和app.config文件的替代方法 - Alternative to web.config and app.config files for configuring WCF WCF何时使用app.config或web.config? - When does WCF use app.config or web.config? WCF服务库配置(App.config)和Web应用程序配置(Web.config)问题 - WCF Service Library Configuration (App.config) And Webapplication Config(Web.config) Issue WCF:在我的app.config / web.config中使用我的“自定义”ServiceHost来获取我的wcf服务? - WCF: Using my “custom” ServiceHost in my app.config/web.config for my wcf service? app.config或web.config中的配置与WCF中的代码之间的关系 - relationship between configuration in app.config or web.config and code in WCF 从类库中调用WCF服务:App.Config与Web.Config? - Calling WCF service from class library: App.Config vs Web.Config? 将WCF服务Web.config移植到Windows服务App.config - Porting WCF Service Web.config to Windows Service App.config app.config文件是否为使用IIS的WCF服务web.config文件等Windows服务公开? - Is app.config file exposed for Windows Service like WCF service web.config file using IIS? web.config与组件的App.config - web.config Vs App.config for Assemblies WCF Web 服务未部署在 localhost ... web.config ... 端点 - WCF Web Service not deploying on localhost … web.config … endpoints
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM