Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SiteLimits Class

IIS 7.0

Exposes connection-related limits for a Web site.

Namespace:  Microsoft.Web.Administration
Assembly:  Microsoft.Web.Administration (in Microsoft.Web.Administration.dll)
'Declaration
PublicNotInheritableClassSiteLimits _
	InheritsConfigurationElement
'Usage
DiminstanceAsSiteLimits

The SiteLimits type exposes the following members.

  NameDescription
Public propertyAttributesGets a configuration attribute collection that contains the list of attributes for this element. (Inherited from ConfigurationElement.)
Public propertyChildElementsGets all the child elements of the current element. (Inherited from ConfigurationElement.)
Public propertyConnectionTimeoutGets or sets the period of time that IIS 7 waits before it considers a connection inactive and terminates it.
Public propertyElementTagNameGets the XML tag name of the current element. (Inherited from ConfigurationElement.)
Public propertyIsLocallyStoredGets a value indicating whether the configuration element is stored in a particular configuration file. (Inherited from ConfigurationElement.)
Public propertyItemGets or sets an attribute with the specified name. (Inherited from ConfigurationElement.)
Public propertyMaxBandwidthGets or sets the maximum network bandwidth, in bytes per second, used for IIS 7.
Public propertyMaxConnectionsGets or sets the maximum number of simultaneous connections to a server.
Public propertyMethodsGets a collection of methods for the configuration element. (Inherited from ConfigurationElement.)
Public propertyRawAttributesGets the raw attribute names and values for the current configuration element. (Inherited from ConfigurationElement.)
Public propertySchemaGets the schema for the current element. (Inherited from ConfigurationElement.)
Top
  NameDescription
Public methodDelete (Inherited from ConfigurationElement.)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetAttributeReturns a ConfigurationAttribute object that represents the requested attribute. (Inherited from ConfigurationElement.)
Public methodGetAttributeValueReturns the value of the specified attribute. (Inherited from ConfigurationElement.)
Public methodGetChildElement(String)Returns a child element that is under the current configuration element and has the specified name. (Inherited from ConfigurationElement.)
Public methodGetChildElement(String, Type)Returns a child element that is under the current configuration element and has the specified name and type. (Inherited from ConfigurationElement.)
Public methodGetCollection()()()()Returns the default collection for the current configuration element. (Inherited from ConfigurationElement.)
Public methodGetCollection(String)Returns all configuration elements that belong to the current configuration element. (Inherited from ConfigurationElement.)
Public methodGetCollection(Type)Returns the configuration element that has the specified type and is under the current configuration element. (Inherited from ConfigurationElement.)
Public methodGetCollection(String, Type)Returns the configuration element that has the specified name and type and is under the current configuration element. (Inherited from ConfigurationElement.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetMetadataReturns metadata values from the element schema. (Inherited from ConfigurationElement.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodSetAttributeValueSets the value of the specified attribute. (Inherited from ConfigurationElement.)
Public methodSetMetadataSets metadata values from the element schema. (Inherited from ConfigurationElement.)
Public methodToString (Inherited from Object.)
Top

The SiteLimits object configures connection-related limits for a Web site. You can use this class to prevent a site from taxing the resources of a server beyond limits that you define.

The following example demonstrates the properties of the SiteLimits class. This example retrieves the Site objects in the service module, modifies the SiteLimits property values, places the Site object (including the SiteLimits object) into a property bag, and displays the property values in the page module.

Service module:

'' Gets the site collection from the server.
<ModuleServiceMethod(PassThrough:=True)> _
Public Function GetSiteCollection() As ArrayList
    '' Use an ArrayList to transfer objects to the client.
    Dim arrayOfSiteBags As New ArrayList
    Dim serverManager As New ServerManager
    Dim siteCollection As SiteCollection = serverManager.Sites
    Dim site As Site
    For Each site In siteCollection
        Dim dirty As Boolean = False
        '' Check the connection timeout. If > 300 seconds reset to 2 minutes.
        If (site.Limits.ConnectionTimeout > TimeSpan.FromSeconds(300)) Then
            site.Limits.ConnectionTimeout = TimeSpan.FromMinutes(2)
            dirty = True
        End If
        '' Check the maximum bandwidth. If <100000 reset to 4294967295.
        If (site.Limits.MaxBandwidth < &H186A0) Then
            site.Limits.MaxBandwidth = &HFFFFFFFF
            dirty = True
        End If
        '' Check the maximum connections. If <100 reset to 150.
        If (site.Limits.MaxConnections < 100) Then
            site.Limits.MaxConnections = 150
            dirty = True
        End If
        If dirty Then
            serverManager.CommitChanges()
        End If
        Dim siteBag As New PropertyBag
        siteBag.Item(0) = site
        arrayOfSiteBags.Add(siteBag)
    Next
    Return arrayOfSiteBags
End Function


Page module:

Me._serviceProxy = DirectCast(MyBase.Connection.CreateProxy(MyBase.Module, GetType(ServerManagerDemoModuleServiceProxy)), ServerManagerDemoModuleServiceProxy)
'' Get the site collection.
Dim siteCollectionArray As ArrayList = Me._serviceProxy.GetSiteCollection
Dim sitedisplay As String = Nothing
sitedisplay = ("There are " & siteCollectionArray.Count.ToString & " sites." & ChrW(10))
Dim bag As PropertyBag
For Each bag In siteCollectionArray
    Dim site As Site = DirectCast(bag.Item(0), Site)
    Dim CS$0$0003 As Object = sitedisplay
    sitedisplay = String.Concat(New Object() { CS$0$0003, "   ID: ", site.Id, " - ", site.Name, ChrW(10) })
    '' Get the application collection for the site.
    Dim applicationCollection As ApplicationCollection = site.Applications
    CS$0$0003 = sitedisplay
    sitedisplay = String.Concat(New Object() { CS$0$0003, "      has ", applicationCollection.Count, " applications:" & ChrW(10) })
    Dim application As Application
    For Each application In applicationCollection
        Dim CS$0$0006 As String = sitedisplay
        sitedisplay = String.Concat(New String() { CS$0$0006, "        path: ", application.Path, ": in apppool - ", application.ApplicationPoolName, ChrW(10) })
    Next
    '' Get the Limits for the site.
    Dim siteLimits As SiteLimits = site.Limits
    sitedisplay = (sitedisplay & ChrW(10) & "      SiteLimits:" & ChrW(10))
    sitedisplay = (sitedisplay & "        is limited to " & siteLimits.MaxConnections.ToString & " connections." & ChrW(10))
    CS$0$0003 = sitedisplay
    sitedisplay = String.Concat(New Object() { CS$0$0003, "        with a max bandwidth of ", siteLimits.MaxBandwidth, " bytes/sec." & ChrW(10) })
    CS$0$0003 = sitedisplay
    sitedisplay = String.Concat(New Object() { CS$0$0003, "        timeout of ", siteLimits.ConnectionTimeout, " minutes." & ChrW(10) & ChrW(10) })
Next
Me.testLabel.Text = sitedisplay


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)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.