Walkthrough: Creating and Registering a Custom HTTP Module
Posted chucklu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Walkthrough: Creating and Registering a Custom HTTP Module相关的知识,希望对你有一定的参考价值。
Walkthrough: Creating and Registering a Custom HTTP Module
This walkthrough illustrates the basic functionality of a custom HTTP module. An HTTP module is called on every request in response to the BeginRequest and EndRequest events. As a result, the module runs before and after a request is processed.
If the ASP.NET application is running under IIS 6.0, you can use HTTP modules to customize requests for resources that are serviced by ASP.NET. This includes ASP.NET Web pages (.aspx files), Web services (.asmx files), ASP.NET handlers (.ashx files), and any file types that you have mapped to ASP.NET. If the ASP.NET application is running under IIS 7.0, you can use HTTP modules to customize requests for any resources that are served by IIS. This includes not just ASP.NET resources, but html files (.htm or .html files), graphics files, and so on. For more information, see ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0 and ASP.NET Application Life Cycle Overview for IIS 7.0.
The example module in this topic adds a message to the requested ASP.NET Web page at the beginning of any HTTP request. It adds another message after the page has been processed. The module includes code that makes sure that it does not add text to a request for any other file type.
Each event handler is written as a private method of the module. When the registered events are raised, ASP.NET calls the appropriate handler in the module, which writes information to the ASP.NET Web page.
Tasks illustrated in this walkthrough include the following:
-
How to create the code for an HTTP module.
-
How to register the module in the Web.config file.
Prequisites
In order to complete this walkthrough, you will need:
- Visual Studio or Visual Web Developer.
The walkthrough also assumes that you are working with IIS 6.0 or IIS 7.0. However, you can see the functionality of the module even if you run the ASP.NET Development Server.
以上是关于Walkthrough: Creating and Registering a Custom HTTP Module的主要内容,如果未能解决你的问题,请参考以下文章
7.3 Models -- Creating And Deleting Records
2. creating and destroying objects
Understanding and Creating OWIN Middlewares - Part 1
Effective Java P2 Creating and Destroying Objects
Creating Excel files with Python and XlsxWriter——Introduction
Active Directory - Creating Public and Personnel Share Folders via Script