Lora
Lora

Reputation: 95

WCF Transport Security

i have WSHttpBinding and ServiceHost in my code. how can i set httpsGetEnabled and mexHttpsBinding from code behind?

Upvotes: 1

Views: 220

Answers (1)

Menahem
Menahem

Reputation: 4144

ServiceHost host = new ServiceHost(typeof(MyService));
ServiceMetadataBehavior metadataBehavior;
metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();

if(metadataBehavior == null)
{
    Debug.Assert(BaseAddresses.Any(baseAddress=>baseAddress.Uri.Scheme == "http"));
    metadataBehavior = new ServiceMetadataBehavior();
    metadataBehavior.HttpGetEnabled = true;
    host.Description.Behaviors.Add(metadataBehavior);
}

host.Open();

Upvotes: 1

Related Questions