Click here to Skip to main content
12,890,954 members (50,742 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET .NET WCF .NET4
Hi Guys,

I have a web site which is using two WCF REST services. one of these rest services is just valid when the application is working in the QA env. so I am looking to find a way to disable this one when publishing to production.

How can I disable a REST wcf which is hosted in IIS in config file?

note: if I remove the service configuration part from web config it will use the default configuration! So the service still working!

any idea?

Thank you.
Posted 1-Oct-12 14:40pm
Ashraff Ali Wahab 1-Oct-12 23:39pm
You can have two config one is Web.Release.config and Web.Debug.config and use it appropriately.
aidin Tajadod 2-Oct-12 12:43pm
Thanks, but my question is how to configure it in web config as a disabled service?
Ashraff Ali Wahab 2-Oct-12 14:21pm
I though you configured the URL's in the config.In one config have both teh URLS and in one have only one URL.If I am workng could you post your config file.
aidin Tajadod 2-Oct-12 15:11pm
Thanks for the answer, actually I found the solution! any way thank you.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

As mentioned in comments, best way to move ahead will be to have defined Web.Config files for QA & Production - Web.Config Transformation

Following MSDN Blog entry explains it: ASP.NET Web Projects: web.debug.config & web.release.config[^]


This is the config file which developers should use locally. Ideally you should get this to be standardized. For instance you could use localhost for DB strings, and what not. You should strive for this to work on dev machines without changes.


This is the transform that is applied when you publish your application to the development staging environment. This would make changes to the web.config which are required for the target environment.


This is the transform that is applied when you publish your application to the "production" environment. Obviously you'll have to be careful with passwords depending on your application/team.

More details:
MSDN: How to: Transform Web.config When Deploying a Web Application Project[^]
MSDN: Transforming a Web.Config File for Deployment[^]
Supporting Development and Release web.config in ASP.NET[^]
aidin Tajadod 2-Oct-12 12:41pm
Thanks for the answer,but my question is how to make it disable in config file? I could not find a way to do so!
Sandeep Mewara 2-Oct-12 13:19pm
If you would have gone through links you would have got that switching web.config file one with enabled and other with disabled key would do the trick.
aidin Tajadod 2-Oct-12 14:10pm
OK, I think you did not get my question! I don't have problem switching them, I do not know how to change the web config so to disable it!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

For those who have the same problem,
I had defined my svc file like this:
<![CDATA[<%@ ServiceHost Language="C#" 

by doing this, It seems IIS (or ...) activates my service even if I don't have any configuration in my web.config! So the I removed the Factory=".." from the svc file. by doing this, I have to define it in the config file otherwise it will not work, so I added this extra lines to my config files:

<servicehostingenvironment aspnetcompatibilityenabled="true">
               <add relativeaddress="ServiceName.svc" service="ServiceName" factory="System.ServiceModel.Activation.WebServiceHostFactory" />

Now every thing is fine, when ever I want to disable this service, I can remove the related settings in the config file!

Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100