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