Many times, we create a new xxx.aspx page and xxx.aspx.cs file, but to achieve a very simple feature, such as: output XMLDOM, logout and jump, there is no HTML output, very trouble, need Create a new page, delete excess HTML and write processing code in Page_Load. It doesn't matter if you use httphandler.
Custom HTTP handlers can be written in any language that meets the public language specification (CLS) to handle specific, predefined types of HTTP requests. In response to these specific requests are executable code defined in the HTTPHandler class, not a regular ASP or ASP.NET web page. The HTTP handler provides you with a way to interact with the low-level requests and response services of the IIS Web server while providing a feature that is extremely simple than the ISAPI extension but the programming model is simpler.
For example, I now need to implement a logout.aspx page that is logged out and jump. The following example mainly implements a request to respond to the page named Logout.aspx, implement logout and jump. All requests for Logout.aspx are provided by the logoutttphandler in the namespace Webuc.httphandler included in the assembly Webuc.dll.
Modify Web.config, add the following script in
Below is the code of the logouthttphandler, inherit excuse, override methods, and attributes.
Using system.web; using system.Web.Caching; use system.web.security;
Namespace Webuc.httphandler: IHTTPHANDLER {///
///
After compiling, I can use http://**/logout.aspx to implement the logout, and in fact, there is no logout.aspx file in my web directory, and this skill can be used in many ways. For example, prevent the chain, download statistics, etc.