Share via


HttpHandlerActionCollection.Add(HttpHandlerAction) 方法

定義

HttpHandlerAction 物件加入集合。

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

參數

httpHandlerAction
HttpHandlerAction

要新增到集合的 HttpHandlerAction 物件。

例外狀況

要加入的 HttpHandlerAction 物件已經存在於集合中,或者集合是唯讀的。

範例

下列程式碼範例示範如何建立 HttpHandlerAction 物件,並將其新增至集合。

// Add a new HttpHandlerAction to the Handlers property HttpHandlerAction collection.
httpHandlersSection.Handlers.Add(new HttpHandlerAction(
    "Calculator.custom", 
    "Samples.Aspnet.SystemWebConfiguration.Calculator, CalculatorHandler", 
    "GET", 
    true));
' Add a new HttpHandlerAction to the Handlers property HttpHandlerAction collection.
httpHandlersSection.Handlers.Add(new HttpHandlerAction( _
    "Calculator.custom", _
    "Samples.Aspnet.SystemWebConfiguration.Calculator, CalculatorHandler", _
    "GET", _
    true))

備註

使用這個方法之前,您必須先建立 HttpHandlerAction 物件,並使用適當的名稱和型別加以初始化。 之後,您可以將剛建立的物件新增至集合。

注意

ASP.NET 先搜尋應用程式私人 Bin 目錄中的處理常式元件 DLL,然後在系統組件快取中搜尋。

集合不得已經包含 HttpHandlerAction 具有相同 VerbPath 屬性的物件。

適用於