다음을 통해 공유


HttpCookieContainerBindingElement Class

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

Enables management of how HTTP cookies are handled in HTTP requests and responses.

Inheritance Hierarchy

System.Object
  System.ServiceModel.Channels.BindingElement
    System.ServiceModel.Channels.HttpCookieContainerBindingElement

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

Syntax

'Declaration
Public Class HttpCookieContainerBindingElement _
    Inherits BindingElement
public class HttpCookieContainerBindingElement : BindingElement

The HttpCookieContainerBindingElement type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows Phone HttpCookieContainerBindingElement() Initializes a new instance of the HttpCookieContainerBindingElement class.
Protected methodSupported by Silverlight for Windows Phone HttpCookieContainerBindingElement(HttpCookieContainerBindingElement) Initializes a new instance of the HttpCookieContainerBindingElement class from a specified binding element.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone BuildChannelFactory<TChannel> Initializes a channel factory for producing channels of a specified type from the binding context. (Overrides BindingElement.BuildChannelFactory<TChannel>(BindingContext).)
Public methodSupported by Silverlight for Windows Phone CanBuildChannelFactory<TChannel> Returns a value that indicates whether the binding element can build a channel factory for a specific type of channel. (Inherited from BindingElement.)
Public methodSupported by Silverlight for Windows Phone Clone Returns a copy of the current binding element object. (Overrides BindingElement.Clone().)
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetProperty<T> Returns a typed object requested, if present, from the appropriate layer in the binding stack. (Overrides BindingElement.GetProperty<T>(BindingContext).)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

You can specify an instance of CookieContainer to be used when issuing an HTTP request. Any cookies in the CookieContainer applicable to the request will automatically be included when the HTTP request is made, and any cookies that are returned as part of the HTTP response will automatically be placed in the CookieContainer.

The same CookieContainer instance can be used for multiple channels, which is often useful when one service is used to provide cookies for authentication and another service requires these authentication cookies provided by the first service. To gain access to the CookieContainer instance, call GetProperty<T>() on a channel constructed from a binding that included the HttpCookieContainerBindingElement, using the IHttpCookieContainerManager type parameter. Then, access the CookieContainer property. The property is nulla null reference (Nothing in Visual Basic) by default, signifying that no CookieContainer should be used.

Using HttpCookieContainerBindingElement to manage cookies is necessary only when you have registered an alternative HTTP stack using RegisterPrefix. The default browser-based HTTP stack in Silverlight 5 automatically uses the browser’s cookie repository and does not require this mechanism. If you attempt to set a CookieContainer using this mechanism with the browser-based HTTP stack, the channel will throw an exception when attempting to issue an HTTP request.

NoteNote:

The HttpCookieContainerBindingElement works only with the HttpTransportBindingElement and HttpsTransportBindingElement transport binding elements.

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.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.