How to specify AddressFilterMode.Any declaratively

Viewed 10708

There are lots of answers stating that AddressFilterMode.Any needs to be added as a code attribute when you can create an extension behavior for WCF that does the same thing.

How can you specify AddressFilterMode.Any programmatically

2 Answers

If you want to specify it in code while creating a service host:

host.Description.Behaviors.Find<ServiceBehaviorAttribute>().AddressFilterMode = AddressFilterMode.Any;

or

host.Description.Behaviors.Add(new ServiceBehaviorAttribute { AddressFilterMode = AddressFilterMode.Any });

Depending on whether your service already has a ServiceBehaviorAttribute or not.

Related