Analysis of IHttpModule and IHttpHandler

Source: Internet
Author: User
Keywords Http nbsp; dler this on
Tags analysis application can find code development find http learn

Recent development involves some use of ihttpmodule and IHttpHandler, just reserve enough, grasp the query MSDN learn a bit, will learn a bit record.

I. IHttpModule

The code to view this interface can be found to consist of two methods:

public interface ihttpmodule{void Dispose (); void Init (HttpApplication context); }

Seeing two methods and method tags, you know what this IHttpModule interface does, and the Init method passes in a HttpApplication parameter that provides access to common methods, properties, and events for all application objects within the ASP.net application. Includes access to methods, properties, and events under HttpApplication. What about the specifics?

Including all the objects that we often use, application,context,event,modules,request,response,server,session,site,user,beginrequest, EndRequest and so on, there is a method in the context where context.rewritepath can be used to rewrite URLs, which means that as soon as you add a class that inherits the IHttpModule interface in the App_Code, After adding this module to Webconfig, the class can handle all the methods, properties, and events of the global application.

1. A test was done for commonly used operations:

The application will output the contents of this module to each requested page.

2. For URL rewrite tests are as follows:

Explains that when a user requests a page, the URL is rewritten if the request path does not include custom, but the test fails and is studying the use of the RewritePath method.

Ii. IHttpHandler

This interface consists of a method of a property

public interface ihttphandler{BOOL IsReusable {get;}    void ProcessRequest (HttpContext context); }

IsReusable gets a value that indicates whether the System.Web.IHttpHandler instance can be used by other requests.

System.Web.HttpContext object that provides references to internal server objects (such as request, Response, session, and server) that are used to service HTTP requests.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.