共用方式為


SiteLimits 類別

定義

公開網站的連線相關限制。

public ref class SiteLimits sealed : Microsoft::Web::Administration::ConfigurationElement
public sealed class SiteLimits : Microsoft.Web.Administration.ConfigurationElement
type SiteLimits = class
    inherit ConfigurationElement
Public NotInheritable Class SiteLimits
Inherits ConfigurationElement
繼承

範例

下列範例示範 類別的屬性 SiteLimits 。 本範例會 Site 擷取服務模組中的物件、修改 SiteLimits 屬性值、將 Site 物件 (包括 SiteLimits 物件) 到屬性包中,並在頁面模組中顯示內容值。

服務模組:

// Gets the site collection from the server.
[ModuleServiceMethod(PassThrough = true)]
public ArrayList GetSiteCollection()
{
    // Use an ArrayList to transfer objects to the client.
    ArrayList arrayOfSiteBags = new ArrayList();

    ServerManager serverManager = new ServerManager();
    SiteCollection siteCollection = serverManager.Sites;
    foreach (Site site in siteCollection)
    {
        Boolean dirty = false;
        // Check the connection timeout. If > 300 seconds reset to 2 minutes.
        if (site.Limits.ConnectionTimeout > TimeSpan.FromSeconds(300))
        {
            site.Limits.ConnectionTimeout = TimeSpan.FromMinutes(2);
            dirty = true;
        } 
        // Check the maximum bandwidth. If <100000 reset to 4294967295.
        if (site.Limits.MaxBandwidth < 100000)
        {
            site.Limits.MaxBandwidth = 4294967295;
            dirty = true;
        }
        // Check the maximum connections. If <100 reset to 150.
        if (site.Limits.MaxConnections < 100)
        {
            site.Limits.MaxConnections = 150;
            dirty = true;
        }
        if (dirty)
        {
            serverManager.CommitChanges();
        }
        PropertyBag siteBag = new PropertyBag();
        siteBag[ServerManagerDemoGlobals.SitesArray] = site;
        arrayOfSiteBags.Add(siteBag);
    }
    return arrayOfSiteBags;
}

頁面模組:

_serviceProxy = (ServerManagerDemoModuleServiceProxy)
    Connection.CreateProxy(Module, typeof(ServerManagerDemoModuleServiceProxy));
    
// Get the site collection.
ArrayList siteCollectionArray = _serviceProxy.GetSiteCollection();
string sitedisplay = null;
sitedisplay = "There are " + siteCollectionArray.Count.ToString() + " sites.\n";
foreach (PropertyBag bag in siteCollectionArray)
{
    Site site = (Site)bag[ServerManagerDemoGlobals.SitesArray];
    sitedisplay += "   " + "ID: " + site.Id + " - " + site.Name + "\n";
    
    // Get the application collection for the site.
    ApplicationCollection applicationCollection = site.Applications;
    sitedisplay += "      has " + applicationCollection.Count + " applications:\n";
    foreach (Microsoft.Web.Administration.Application application in applicationCollection)
    {
        sitedisplay += "        path: " + application.Path + 
            ": in apppool - " + application.ApplicationPoolName + "\n";
    }

    // Get the Limits for the site.
    SiteLimits siteLimits = site.Limits;
    sitedisplay += "\n      SiteLimits:\n";
    sitedisplay += "        is limited to " + siteLimits.MaxConnections.ToString() + " connections.\n";
    sitedisplay += "        with a max bandwidth of " + siteLimits.MaxBandwidth + " bytes/sec.\n";
    sitedisplay += "        timeout of " + siteLimits.ConnectionTimeout + " minutes.\n\n";
}
                testLabel.Text = sitedisplay;

備註

物件 SiteLimits 會設定網站的連線相關限制。 您可以使用這個類別來防止網站對伺服器的資源進行分類,而超出您定義的限制。

屬性

Attributes

取得組態屬性集合,其中包含這個專案的屬性清單。

(繼承來源 ConfigurationElement)
ChildElements

取得目前專案的所有子專案。

(繼承來源 ConfigurationElement)
ConnectionTimeout

取得或設定 IIS 7 在將連線視為非使用中並終止之前所等候的時間週期。

ElementTagName

公開網站的連線相關限制。

(繼承來源 ConfigurationElement)
IsLocallyStored

取得值,指出組態專案是否儲存在特定組態檔中。

(繼承來源 ConfigurationElement)
Item[String]

取得或設定具有指定名稱的屬性。

(繼承來源 ConfigurationElement)
MaxBandwidth

取得或設定 IIS 7 所使用的網路頻寬上限,以每秒位元組為單位。

MaxConnections

取得或設定與伺服器同時連線的最大數目。

MaxUrlSegments

公開網站的連線相關限制。

Methods

取得組態專案的方法集合。

(繼承來源 ConfigurationElement)
RawAttributes

公開網站的連線相關限制。

(繼承來源 ConfigurationElement)
Schema

取得目前專案的架構。

(繼承來源 ConfigurationElement)

方法

Delete()

公開網站的連線相關限制。

(繼承來源 ConfigurationElement)
GetAttribute(String)

ConfigurationAttribute傳回 物件,表示要求的屬性。

(繼承來源 ConfigurationElement)
GetAttributeValue(String)

傳回指定之屬性的值。

(繼承來源 ConfigurationElement)
GetChildElement(String)

傳回目前組態專案下且具有指定名稱的子專案。

(繼承來源 ConfigurationElement)
GetChildElement(String, Type)

傳回目前組態專案下且具有指定名稱和類型的子專案。

(繼承來源 ConfigurationElement)
GetCollection()

傳回目前組態專案的預設集合。

(繼承來源 ConfigurationElement)
GetCollection(String)

傳回屬於目前組態專案的所有組態專案。

(繼承來源 ConfigurationElement)
GetCollection(String, Type)

傳回具有指定名稱和型別的組態專案,且位於目前的組態專案底下。

(繼承來源 ConfigurationElement)
GetCollection(Type)

傳回具有指定型別且位於目前組態專案下的組態專案。

(繼承來源 ConfigurationElement)
GetMetadata(String)

從專案架構傳回中繼資料值。

(繼承來源 ConfigurationElement)
SetAttributeValue(String, Object)

設定指定屬性的值。

(繼承來源 ConfigurationElement)
SetMetadata(String, Object)

從專案架構設定中繼資料值。

(繼承來源 ConfigurationElement)

適用於