简体   繁体   English

WCF mini web.config更改

[英]WCF mini web.config change

I am developing WCF project under DotNet4 environment. 我正在DotNet4环境下开发WCF项目。 WCF is new to me. WCF对我来说是新手。 I am surprised that it is required to add each new service to web.config. 我很惊讶需要将每个新服务添加到web.config。 To avoid we accidentally deploy web.config with DEV database connection string to production server, is there any way that I can either add new services to an external configure file or "register" service inside each new service itself? 为避免我们意外地将带有DEV数据库连接字符串的web.config部署到生产服务器,是否可以通过任何方式将新服务添加到外部配置文件或在每个新服务本身内部“注册”服务?

I did some researches. 我做了一些研究。 The more I read, the more I confused. 我读得越多,我就越困惑。 It is possible to create WCF web service without changing web.config at all? 是否可以创建WCF Web服务而根本不更改web.config?

Thanks for any help in advanced. 感谢您的高级帮助。

I am not expert in WCF, but from what I read, you have 2 problem: 我不是WCF专家,但是从我的阅读中,您有2个问题:

  1. you don't want the development connection string to be on the production config file: to solve this, there is something called config transformation which essentialy change config setting when compiling your project. 您不希望开发连接字符串出现在生产配置文件中:要解决此问题,有一个名为config transform的东西,在编译项目时必须更改配置设置。 read: 读:

    http://www.codeproject.com/Tips/559849/Transform-Web-Config-when-Deploying-a-Web-Applicat http://www.codeproject.com/Tips/559849/Transform-Web-Config-when-Deploying-a-Web-Applicat

    http://www.asp.net/web-forms/tutorials/deployment/visual-studio-web-deployment/web-config-transformations http://www.asp.net/web-forms/tutorials/deployment/visual-studio-web-deployment/web-config-transformations

    edit: above work for website application, if you need wcf to have similar function, checkout http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx 编辑:以上工作适用于网站应用程序,如果您需要wcf具有类似功能,请检出http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx

  2. Is it possible to dfine service programatically? 是否可以通过程序定义服务? have a look: http://msdn.microsoft.com/en-us/library/hh205277(v=vs.110).aspx 看看: http : //msdn.microsoft.com/zh-cn/library/hh205277(v=vs.110).aspx

    How to programatically create a WCF service and its metadata on the same URL 如何以编程方式在同一URL上创建WCF服务及其元数据

    How can I register a WCF service programmatically within an IIS environment 如何在IIS环境中以编程方式注册WCF服务

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM