Using httpmodule for URL rewriting

Source: Internet
Author: User

1. modify the configuration file:

 

2. Compile the httpmodule class:

Using system; using system. collections. generic; using system. LINQ; using system. web; // URL rewriting summary /// 1. create a class file httpmodule. CS // 2. method for implementing the ihttpmodule interface public class httpmodule: ihttpmodule {// clear the resource public httpmodule () {} public void dispose () {} // initialization // public void Init (httpapplication context) {// 3. add the event processing method context to the initialization method. beginrequest + = new eventhandler (beginrequest); context. endrequest + = new E Venthandler (endrequest);} // 4. write the public void beginrequest (Object sender, eventargs e) {httpapplication APP = sender as httpapplication; // app. response. write ("Start processing requests! "); // 4.1 intercepted request URL string url = app. request. rawurl; // 4.2 determines whether the URL meets the requirements and whether to resend to the specified page if (URL. lastindexof (". html ")> 0) {// forward to the specified page app. server. transfer ("~ /Httpmoudle/urlrewrite. aspx ") ;}} public void endrequest (Object sender, eventargs e) {httpapplication APP = sender as httpapplication; // app. response. write ("End Processing request! ");}}

Better!

Using httpmodule for URL rewriting

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.