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
- 繼承
範例
以下程式碼範例說明如何從現有網頁應用程式的設定檔取得該 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 區段。
Note
該 urlMappings 區塊包含 UrlMapping 將顯示給使用者的 URL 映射到你網頁應用程式中存在的 URL 的物件。 可以 UrlMappingsSection 根據區段屬性所定義的限制,將資訊寫入設定檔的相關區段,該屬性 AllowDefinition 的值為 MachineToApplication。 任何嘗試在階層結構中不允許的層級寫入設定檔,解析器都會產生錯誤訊息。 不過,你可以用這個類別讀取階層中任何層級的設定資訊。
建構函式
| 名稱 | Description |
|---|---|
| UrlMappingsSection() |
初始化 UrlMappingsSection 類別的新執行個體。 |