I need to implement following using code:
<basicHttpBinding>
<binding name="NewBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
Is there any samples available? I'm working on WCF REST service and register routes manually. Placing this config into configuration doesn't work. I'd like to get it setup programmatically if possible. Also, at what point in code I should do it?
EDIT:
My service Routed in Global.asax like so:
foreach (var account in cmc.Accounts.Where(aa => aa.IsActive).ToList())
{
RouteTable.Routes.Add(
new ServiceRoute(
account.AccountId + "/mobile", new MyServiceHostFactory(), typeof(MobileService)));
}
And I have my own ServiceHost
public class MyServiceHost : WebServiceHost
{
private readonly Type _serviceType;
private readonly CompositionContainer _container;
public MyServiceHost(Type serviceType, CompositionContainer container, params Uri[] baseAddresses)
: base(serviceType, baseAddresses)
{
_serviceType = serviceType;
_container = container;
}
protected override void OnOpening()
{
if (Description.Behaviors.Find<MyServiceBehavior>() == null)
{
Description.Behaviors.Add(new MyServiceBehavior(_serviceType, _container));
}
base.OnOpening();
}
}