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.

C#
public void Remove(string name);

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.

C#

// Remove the module from the collection.
if (!httpModulesSection.SectionInformation.IsLocked)
{
    modulesCollection.Remove("TimerModule");
    configuration.Save();
}

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

.NET Framework 4.8.1 ja muut versiot
Tuote Versiot
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Remove(HttpModuleAction)

Removes an HttpModuleAction object from the collection.

C#
public void Remove(System.Web.Configuration.HttpModuleAction action);

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.

C#
// 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();
}

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

.NET Framework 4.8.1 ja muut versiot
Tuote Versiot
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1