tags:

views:

264

answers:

2

Is there any way I can accomplish the following:

Single Web.config file for a .net web application. the web application exposes a number of WCF services for consumption by javascript.

Production requires ssl, so all these services are forced over ssl.

Development does not allow ssl, (ASP.NET development server)

How can I configure this so that production will utilize an HTTPS endpoint, and development will utilize an HTTP endpoint for the same service?

Adding two endpoints to the same service doesn't work, because when it tries to connect to the HTTP endpoint it throws an error since the asp.net development server doesn't support the https endpoint.

A: 

I'm not certain that this is the best solution to your problem, but one way of doing this would be to declare in the config file a variable to indicate what environment this is running in (dev or prod). If you configure two endpoints, you could say in your hosting code,

if environment=="dev", then host the service on endpoint A.

if environment=="eval", then host the service on endpoint B.

Rice Flour Cookies
+1  A: 

I solved this by using a ServiceHostFactory to generate the appropriate bindings for me.

It was a little awkward at first, having less control, but works out better in the end.

this is the line that was key, I put it in my .svc file:

Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory"

DNeoMatrix