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 類別 (Class) 提供以程式的方法,存取和修改組態檔的 urlMappings 區段。
注意
區 urlMappings 段包含 UrlMapping 物件,這些物件會將顯示的 URL 對應至 Web 應用程式中存在的 URL。
UrlMappingsSection可以根據值為 MachineToApplication 的 section 屬性 AllowDefinition 所定義的限制,將資訊寫入組態檔的相關區段。 在階層中不允許的層級寫入組態檔的任何嘗試,都會產生剖析器所產生的錯誤訊息。 不過,您可以使用這個類別來讀取階層中任何層級的組態資訊。
建構函式
| UrlMappingsSection() |
初始化 UrlMappingsSection 類別的新執行個體。 |