共用方式為


UrlMappingCollection.Add(UrlMapping) 方法

定義

將指定的 UrlMapping 加入至集合。

public:
 void Add(System::Web::Configuration::UrlMapping ^ urlMapping);
public void Add (System.Web.Configuration.UrlMapping urlMapping);
member this.Add : System.Web.Configuration.UrlMapping -> unit
Public Sub Add (urlMapping As UrlMapping)

參數

urlMapping
UrlMapping

要新增到集合的 UrlMapping 物件。

範例

下列程式碼範例會將 UrlMapping 物件新增至 UrlMappingCollection

請參閱類別主題中的 UrlMappingCollection 程式碼範例,以瞭解如何取得集合。


// Create a new UrlMapping object.
urlMapping = new UrlMapping(
  "~/home.aspx", "~/default.aspx?parm1=1");
  
// Add the urlMapping to 
// the collection.
urlMappings.Add(urlMapping);

// Update the configuration file.
if (!urlMappingSection.IsReadOnly())
  configuration.Save();
' Create a new UrlMapping object.
urlMapping = New UrlMapping( _
"~/home.aspx", "~/default.aspx?parm1=1")

' Add the urlMapping to 
' the collection.
urlMappings.Add(urlMapping)

' Update the configuration file.
If Not urlMappingSection.IsReadOnly() Then
    configuration.Save()
End If

適用於

另請參閱