HttpModuleActionCollection.Remove Method

Definition

Removes an HttpModuleAction module from the collection.

Overloads

Remove(String)

Removes an HttpModuleAction object from the collection.

Remove(HttpModuleAction)

Removes an HttpModuleAction object from the collection.

Remarks

To remove a module from its collection, you can use one of listed overloaded methods.

Remove(String)

Removes an HttpModuleAction object from the collection.

public:
 void Remove(System::String ^ name);
public void Remove (string name);
member this.Remove : string -> unit
Public Sub Remove (name As String)

Parameters

name
String

The key that identifies the HttpModuleAction object to remove from the collection.

Exceptions

There is no HttpModuleAction object with the specified key in the collection, the element has already been removed, or the collection is read-only.

Examples

The following example shows how to remove an HttpModuleAction module from the collection.


// Remove the module from the collection.
if (!httpModulesSection.SectionInformation.IsLocked)
{
    modulesCollection.Remove("TimerModule");
    configuration.Save();
}
' Remove the module from the collection.
If Not httpModulesSection.SectionInformation.IsLocked Then
    modulesCollection.Remove("MyModule2Name")
    configuration.Save()
End If

Remarks

This method inserts a <remove> element into the appropriate section of the configuration file for any element defined in a higher-level configuration file. If the element is defined in the appropriate section of the current configuration file, its entry is removed from the configuration file. The object to remove must exist in the collection.

Applies to

Remove(HttpModuleAction)

Removes an HttpModuleAction object from the collection.

public:
 void Remove(System::Web::Configuration::HttpModuleAction ^ action);
public void Remove (System.Web.Configuration.HttpModuleAction action);
member this.Remove : System.Web.Configuration.HttpModuleAction -> unit
Public Sub Remove (action As HttpModuleAction)

Parameters

action
HttpModuleAction

The HttpModuleAction module to remove.

Exceptions

The passed HttpModuleAction object does not exist in the collection, the element has already been removed, or the collection is read-only.

Examples

The following example shows how to remove an HttpModuleAction module from the collection.

// Set the module object.
HttpModuleAction ModuleAction2 = 
    new HttpModuleAction("MyModule2Name",
    "MyModule2Type");

// Remove the module from the collection.
if (!httpModulesSection.SectionInformation.IsLocked)
{
    modulesCollection.Remove(ModuleAction2);
    configuration.Save();
}
' Set the module object.
Dim ModuleAction2 As New HttpModuleAction( _
"MyModule2Name", "MyModule2Type")
' Remove the module from the collection.
If Not httpModulesSection.SectionInformation.IsLocked Then
    modulesCollection.Remove(ModuleAction2)
    configuration.Save()
End If

Remarks

This method inserts a <remove> element into the appropriate section of the configuration file for any element defined in a higher-level configuration file. If the element is defined in the appropriate section of the current configuration file, its entry is removed from the configuration file. The object to remove must exist in the collection.

Applies to