UrlMappingsSection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供对配置部分的 urlMappings 编程访问。 此类不能被继承。
public ref class UrlMappingsSection sealed : System::Configuration::ConfigurationSection
public sealed class UrlMappingsSection : System.Configuration.ConfigurationSection
type UrlMappingsSection = class
inherit ConfigurationSection
Public NotInheritable Class UrlMappingsSection
Inherits ConfigurationSection
- 继承
示例
下面的代码示例演示如何从现有 Web 应用程序的配置文件中获取 UrlMappingsSection 对象。 此外,还显示了配置文件的摘录。
// Get the Web application configuration.
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration(
"/aspnetTest");
// Get the <urlMapping> section.
UrlMappingsSection urlMappingSection =
(UrlMappingsSection)configuration.GetSection(
"system.web/urlMappings");
// Get the url mapping collection.
UrlMappingCollection urlMappings =
urlMappingSection.UrlMappings;
' Get the Web application configuration.
Dim configuration _
As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration( _
"/aspnetTest")
' Get the <urlMapping> section.
Dim urlMappingSection _
As UrlMappingsSection = _
CType(configuration.GetSection( _
"system.web/urlMappings"), UrlMappingsSection)
' Get the url mapping collection.
Dim urlMappings _
As UrlMappingCollection = _
urlMappingSection.UrlMappings
<urlMappings enabled="true">
<add url= "~/home.aspx"
mappedUrl="~/default.aspx?parm1=1"/>
<add url= "~/products.aspx"
mappedUrl="~/default.aspx?parm1=2"/>
</urlMappings>
注解
该 UrlMappingsSection 类提供了一种以编程方式访问和修改 urlMappings 配置文件部分的方法。
注释
该 urlMappings 部分包含将 UrlMapping 向用户显示的 URL 映射到 Web 应用程序中存在的 URL 的对象。 可以根据UrlMappingsSection属性值AllowDefinition为的节属性MachineToApplication定义的限制,将信息写入配置文件的相关节。 在层次结构中不允许的某个级别的配置文件中写入的任何尝试都将导致分析程序生成的错误消息。 但是,可以使用此类在层次结构中的任何级别读取配置信息。
构造函数
| 名称 | 说明 |
|---|---|
| UrlMappingsSection() |
初始化 UrlMappingsSection 类的新实例。 |