ClientTargetSection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
配置 clientTarget
节。 此类不能被继承。
public ref class ClientTargetSection sealed : System::Configuration::ConfigurationSection
public sealed class ClientTargetSection : System.Configuration.ConfigurationSection
type ClientTargetSection = class
inherit ConfigurationSection
Public NotInheritable Class ClientTargetSection
Inherits ConfigurationSection
- 继承
示例
本部分提供两个代码示例。 第一个显示类的 ClientTargetSection 声明性表示形式,还演示了如何以声明方式为类的 ClientTarget 多个属性指定值。 第二个演示如何从配置文件中获取 ClientTargetCollection 对象。 使用此对象来访问 ClientTarget 它包含的对象。
下面的代码示例演示如何以声明方式为 类的 ClientTarget 多个属性指定值。
<clientTarget>
<add alias=
"uplevel" userAgent="Mozilla/5.0 (compatible;MSIE 6.0;Windows NT 5.1)"/>
<add alias="downlevel" userAgent="Generic Downlevel"/>
</clientTarget>
下面的代码示例演示如何从配置文件获取 ClientTargetCollection 对象
// Get the Web application configuration.
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration(
"/aspnetTest");
// Get the <clientTarget> section.
ClientTargetSection clientTargetSection =
(ClientTargetSection)configuration.GetSection(
"system.web/clientTarget");
// Get the client target collection.
ClientTargetCollection clientTargets =
clientTargetSection.ClientTargets;
' Get the Web application configuration.
Dim configuration _
As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration( _
"/aspnetTest")
' Get the <clientTarget> section.
Dim clientTargetSection _
As ClientTargetSection = _
CType(configuration.GetSection( _
"system.web/clientTarget"), _
ClientTargetSection)
' Get the client target collection.
Dim clientTargets _
As ClientTargetCollection = _
clientTargetSection.ClientTargets
注解
类 ClientTargetSection 提供了一种以编程方式访问和修改 clientTarget
配置文件的 节的方法。 它属于包含 ClientTargetCollection 类和 类的 ClientTarget 组。
类 ClientTargetSection 包含对象, ClientTarget 这些对象定义 ASP.NET 服务器控件应呈现内容的别名和关联的目标用户代理对。
构造函数
ClientTargetSection() |
初始化 ClientTargetSection 类的新实例。 |