This topic has not yet been rated - Rate this topic

Binding Class

IIS 7.0

Represents the binding instructions for a Web site.

System..::..Object
  Microsoft.Web.Administration..::..ConfigurationElement
    Microsoft.Web.Administration..::..Binding

Namespace:  Microsoft.Web.Administration
Assembly:  Microsoft.Web.Administration (in Microsoft.Web.Administration.dll)
public class Binding : ConfigurationElement

The Binding type exposes the following members.

  Name Description
Public property Attributes Gets a configuration attribute collection that contains the list of attributes for this element. (Inherited from ConfigurationElement.)
Public property BindingInformation Gets or sets the binding information for the current binding.
Public property CertificateHash Gets or sets the hash of the certificate to bind.
Public property CertificateStoreName Gets or sets the name of the certificate store.
Public property ChildElements Gets all the child elements of the current element. (Inherited from ConfigurationElement.)
Public property ElementTagName Gets the XML tag name of the current element. (Inherited from ConfigurationElement.)
Public property EndPoint Gets the IP endpoint of the binding.
Public property Host Gets the host value of the binding.
Public property IsIPPortHostBinding Gets a value indicating whether the binding is bound to an IP port.
Public property IsLocallyStored Gets a value indicating whether the configuration element is stored in a particular configuration file. (Inherited from ConfigurationElement.)
Public property Item Gets or sets an attribute with the specified name. (Inherited from ConfigurationElement.)
Public property Methods Gets a collection of methods for the configuration element. (Inherited from ConfigurationElement.)
Public property Protocol Gets or sets the protocol the binding will use.
Public property RawAttributes Gets the raw attribute names and values for the current configuration element. (Inherited from ConfigurationElement.)
Public property Schema Gets the schema for the current element. (Inherited from ConfigurationElement.)
Public property UseDsMapper Gets or sets a value indicating whether the binding will use Active Directory mapping.
Top
  Name Description
Public method Delete (Inherited from ConfigurationElement.)
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetAttribute Returns a ConfigurationAttribute object that represents the requested attribute. (Inherited from ConfigurationElement.)
Public method GetAttributeValue Returns the value of the specified attribute. (Inherited from ConfigurationElement.)
Public method GetChildElement(String) Returns a child element that is under the current configuration element and has the specified name. (Inherited from ConfigurationElement.)
Public method GetChildElement(String, Type) Returns a child element that is under the current configuration element and has the specified name and type. (Inherited from ConfigurationElement.)
Public method GetCollection()()()() Returns the default collection for the current configuration element. (Inherited from ConfigurationElement.)
Public method GetCollection(String) Returns all configuration elements that belong to the current configuration element. (Inherited from ConfigurationElement.)
Public method GetCollection(Type) Returns the configuration element that has the specified type and is under the current configuration element. (Inherited from ConfigurationElement.)
Public method GetCollection(String, Type) Returns the configuration element that has the specified name and type and is under the current configuration element. (Inherited from ConfigurationElement.)
Public method GetHashCode (Inherited from Object.)
Public method GetMetadata Returns metadata values from the element schema. (Inherited from ConfigurationElement.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method SetAttributeValue Sets the value of the specified attribute. (Inherited from ConfigurationElement.)
Public method SetMetadata Sets metadata values from the element schema. (Inherited from ConfigurationElement.)
Public method ToString Returns a string representation of the binding object. (Overrides Object..::..ToString()()()().)
Top

Site bindings specify the possible protocols and endpoints that are available for applications that are running on a Web site. A binding specifies how clients and IIS Manager communicate. There can be multiple bindings for any site. 

You can view the bindings for a site in the Site Bindings dialog box in IIS Manager. To open the dialog box, right-click a site node in the Connections pane, and then click Edit Bindings. The Site Bindings dialog box displays the Binding objects in the BindingCollection object for the site.

The following example gets and displays the bindings for each site.


_serviceProxy = (TestDemoModuleServiceProxy)
    Connection.CreateProxy(Module, typeof(TestDemoModuleServiceProxy));

// Get the site collection on this server.
SiteCollection siteCollection = _serviceProxy.GetSiteCollection();
string collectiondisplay = null;
collectiondisplay = "There are " + siteCollection.Count.ToString() + " sites:\n\n";
string sitedisplay = null;
foreach (Site site in siteCollection)
{
    sitedisplay = sitedisplay + site.Name + ": ID= " + site.Id + "\n";
    // Display each property of each bindings.
    string bindingdisplay = null;
    foreach (Microsoft.Web.Administration.Binding binding in site.Bindings)
    {
        bindingdisplay = bindingdisplay + "  Binding:\n   BindingInformation: " + 
            binding.BindingInformation;
        if (binding.Protocol == "https")
        {
             // There is a CertificateHash and  
             // CertificateStoreName for the https protocol only.
            bindingdisplay = bindingdisplay + "\n   CertificateHash: " + 
                binding.CertificateHash + ": ";
            // Display the hash.
            foreach (System.Byte certhashbyte in binding.CertificateHash)
            {
                bindingdisplay = bindingdisplay + certhashbyte.ToString() + " ";
            }
            bindingdisplay = bindingdisplay + "\n   CertificateStoreName: " + 
                binding.CertificateStoreName;
        }
        bindingdisplay = bindingdisplay + "\n   EndPoint: " + binding.EndPoint;
        bindingdisplay = bindingdisplay + "\n   Host: " + binding.Host;
        bindingdisplay = bindingdisplay + "\n   IsIPPortHostBinding: " + binding.IsIPPortHostBinding;
        bindingdisplay = bindingdisplay + "\n   Protocol: " + binding.Protocol;
        bindingdisplay = bindingdisplay + "\n   ToString: " + binding.ToString();
        bindingdisplay = bindingdisplay + "\n   UseDsMapper: " + binding.UseDsMapper + "\n\n";
    }
    sitedisplay = sitedisplay + bindingdisplay;
}
collectiondisplay = collectiondisplay + sitedisplay + "\n";
testLabel.Text = collectiondisplay;


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Not a complete example
Where do the Connection object and the _serviceProxy object come from?  This example is incomplete.  Please update it to include a full workable example.