Name

<httpModules>

Synopsis

<httpModules>
   <add 
      name=moduleName 
      type=typeInfo />
   <remove name=moduleName />
   <clear />
</httpModules>

Adds or removes HttpModules. HttpModules are special classes that participate in the processing of all application requests. Both ASP.NET caching and session state are implemented as HttpModules, as are the authentication and authorization features of ASP.NET.

Scope

Any

Attributes

None

Child Elements

<add>

Adds an HttpModule. The class that implements the HttpModule is specified by the type attribute. This class must implement the IHttpModule interface. The name attribute provides an alias by which the HttpModule can be referred to -- for example, in a later <remove> element.

<remove>

Removes a previously configured HttpModule, based on the specified name attribute. The attribute must match a previously configured <add> element.

<clear>

Clears all previously configured HttpModules.

Example

The example removes the HttpModule for the Session state provider, which can be useful if you’re not using it:

<configuration>
   <system.web>
      <httpModules>
         <remove name="Session" />
      </httpModules>
   </system.web>
</configuration>

Notes

If you’re not using a particular HttpModule, such as the Session state module or authentication modules, you may be able to save overhead by removing these HttpModules from an application’s web.config file by using the <remove> element.

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.