HTTP handler vs HTTP module

后端 未结 8 1421
粉色の甜心
粉色の甜心 2020-12-02 04:21

Can someone explain in less than 2 sentences the difference between both? Yes, I know google can provide hundreds of answers but not one in 2 clear sentences:)

8条回答
  •  感情败类
    2020-12-02 04:58

    HTTP Handler

    HTTP Handler is the process which runs in response to a HTTP request. So whenever user requests a file it is processed by the handler based on the extension. So, custom http handlers are created when you need to special handling based on the file name extension. Let's consider an example to create RSS for a site. So, create a handler that generates RSS-formatted XML. Now bind the .rss extension to the custom handler.

    HTTP Modules

    HTTP Modules are plugged into the life cycle of a request. So when a request is processed it is passed through all the modules in the pipeline of the request. So generally http modules are used for:

    Security: For authenticating a request before the request is handled.

    Statistics and Logging: Since modules are called for every request they can be used for gathering statistics and for logging information.

    Custom header: Since response can be modified, one can add custom header information to the response.

提交回复
热议问题