SiteLimits 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
公开网站的连接相关限制。
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) |