Register the HTTP module in the configuration file
After the HTTP module is created and copied to the bin directory of the Web application or Global Assembly Cache. config or machine. config.
We can use the
Because configuration settings can be inherited, subdirectories inherit configuration settings from the parent directory. As a result, subdirectories may inherit some unwanted HTTP modules (which are part of the parent configuration information). Therefore, we need a method to delete these unnecessary modules. You can use the <remove> node. If you want to delete all HTTP modules inherited from the application, you can use the <clear> node.
The following code is a common example of adding an HTTP module:
- <httpModules>
- <add type="classname, assemblyname" name="modulename" />
- <httpModules>
The following code deletes an HTTP module from an application:
- <httpModules>
- <remove name="modulename" />
- <httpModules>
In the preceding XML:
· The Type attribute specifies the actual Type of the HTTP module in the form of class and part names.
· The Name attribute specifies the friendly Name of the module. Other applications can use this name to identify the HTTP module.
How to Use the HTTP module during ASP. NET running
The HTTP module is used to implement some special functions when ASP. NET is running. The following snippet is from the machine. config file. It displays the HTTP module installed during ASP. NET runtime:
- <httpModules>
- <add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/>
- <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
- <add name="WindowsAuthentication"
- type="System.Web.Security.WindowsAuthenticationModule"/>
- <add name="FormsAuthentication"
- type="System.Web.Security.FormsAuthenticationModule"/>
- <add name="PassportAuthentication"
- type="System.Web.Security.PassportAuthenticationModule"/>
- <add name="UrlAuthorization"
- type="System.Web.Security.UrlAuthorizationModule"/>
- <add name="FileAuthorization"
- type="System.Web.Security.FileAuthorizationModule"/>
- </httpModules>
ASP. NET uses the preceding HTTP modules to provide some services, such as identity authentication and authorization, dialog management, and output buffering. These modules are registered in the machine. config file.
- HTTP module and processing program of ASP. NET
- HTTP module of ASP. NET and request handling process of processing programs
- Execution of the HTTP module and processing program of ASP. NET
- Session Status of HTTP modules and handlers of ASP. NET
- ASP. net http module and processing program module implementation