This documentation is archived and is not being maintained.

ServiceEndpoint.Behaviors Property

Gets the behaviors for the service endpoint.

Namespace: System.ServiceModel.Description
Assembly: System.ServiceModel (in system.servicemodel.dll)

public KeyedByTypeCollection<IEndpointBehavior> Behaviors { get; }
/** @property */
public KeyedByTypeCollection<IEndpointBehavior> get_Behaviors ()

public function get Behaviors () : KeyedByTypeCollection<IEndpointBehavior>

Not applicable.

Property Value

The KeyedByTypeCollection of type IEndpointBehavior that contains the behaviors specified for the service endpoint.

The type of behavior that is accessible from the description hierarchy is scoped to the specific level. From the ServiceEndpoint the IEndpointBehavior is accessible.

If you want access to the IContractBehavior associated with an endpoint instead, you can obtain the contact for the endpoint using the Contract property. Then call the Behaviors property to obtain the KeyedByTypeCollection of the IContractBehavior objects associated with the endpoint.

The following code illustrates how to add a custom Endpoint behavior and then access that behavior:

Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

ServiceEndpoint endpoint = serviceHost.AddServiceEndpoint(
    new WSHttpBinding(),

endpoint.Behaviors.Add(new MyEndpointBehavior());

Console.WriteLine("List all behaviors:");
foreach (IEndpointBehavior behavior in endpoint.Behaviors)
    Console.WriteLine("Behavior: {0}", behavior.ToString());

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0