Share via


BasicHttpSecurity.Mode Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the mode of security for a client configured with a BasicHttpBinding.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Syntax

'Declaration
Public Property Mode As BasicHttpSecurityMode
public BasicHttpSecurityMode Mode { get; set; }

Property Value

Type: System.ServiceModel.BasicHttpSecurityMode
A value in the BasicHttpSecurityMode enumeration. The default value for this property is None.

Exceptions

Exception Condition
ArgumentOutOfRangeException

The value is not a legal value for BasicHttpSecurityMode.

Remarks

The security mode values available to Silverlight clients configured with the BasicHttpBinding are None, Transport, TransportCredentialOnly, and TransportWithMessageCredential.

Examples

            'Constructors set with different security modes
            Dim defaultNoSecurityPDBinding As New PollingDuplexHttpBinding()
            Dim transportSecurityPDBinding As New PollingDuplexHttpBinding(BasicHttpSecurityMode.Transport)
            Dim transportCredentialOnlyPDBinding As New PollingDuplexHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly)

            'Get the BasicHttpSecurity from the binding
            Dim defaultSecurity As BasicHttpSecurity = defaultNoSecurityPDBinding.Security
            Dim transportHttpSecurity As BasicHttpSecurity = transportSecurityPDBinding.Security
            Dim transportCredentialOnlyHttpSecurity As BasicHttpSecurity = transportCredentialOnlyPDBinding.Security

            'Get the defaultSecurityMode
            Dim defaultSecurityMode As BasicHttpSecurityMode = defaultSecurity.Mode
            'Output for binding with no security: None
            Dim txtdefaultSecurityMode As String = defaultSecurityMode.ToString()

            'Get the transportSecurityMode
            Dim tansportSecurityMode As BasicHttpSecurityMode = transportHttpSecurity.Mode
            'Output for binding with transport security: Transport
            Dim txtTransportSecurityMode As String = tansportSecurityMode.ToString()

            'Output txtSecurityMode for binding with transport credential security: TransportCredentialOnly
            Dim txtTransportCredentialOnlySecurityMode As String = transportCredentialOnlyHttpSecurity.Mode.ToString()

            'Change the SecurityMode for a binding
            defaultSecurityMode = BasicHttpSecurityMode.TransportCredentialOnly
            'Output for binding with transport credential only security: TransportCredentialOnly
            Dim txtChangedSecurityMode As String = defaultSecurityMode.ToString()

            //Constructors set with different security modes
            PollingDuplexHttpBinding defaultNoSecurityPDBinding = new PollingDuplexHttpBinding();
            PollingDuplexHttpBinding transportSecurityPDBinding = new PollingDuplexHttpBinding(BasicHttpSecurityMode.Transport);
            PollingDuplexHttpBinding transportCredentialOnlyPDBinding = new PollingDuplexHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);

            //Get the BasicHttpSecurity from the binding
            BasicHttpSecurity defaultSecurity = defaultNoSecurityPDBinding.Security;
            BasicHttpSecurity transportHttpSecurity = transportSecurityPDBinding.Security;
            BasicHttpSecurity transportCredentialOnlyHttpSecurity = transportCredentialOnlyPDBinding.Security;

            //Get the defaultSecurityMode
            BasicHttpSecurityMode defaultSecurityMode = defaultSecurity.Mode;
            //Output for binding with no security: None
            string txtdefaultSecurityMode = defaultSecurityMode.ToString();

            //Get the transportSecurityMode
            BasicHttpSecurityMode tansportSecurityMode = transportHttpSecurity.Mode;
            //Output for binding with transport security: Transport
            string txtTransportSecurityMode = tansportSecurityMode.ToString();

            //Output txtSecurityMode for binding with transport credential security: TransportCredentialOnly
            string txtTransportCredentialOnlySecurityMode = transportCredentialOnlyHttpSecurity.Mode.ToString();

            //Change the SecurityMode for a binding
            defaultSecurityMode = BasicHttpSecurityMode.TransportCredentialOnly;
            //Output for binding with transport credential only security: TransportCredentialOnly
            string txtChangedSecurityMode = defaultSecurityMode.ToString();

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.