语言

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 具有相同 Verb 属性的对象 Path 。

适用于