Sharepoint HttpModule implementation, sharepoint
First, write an IHttpModule implementation class.
Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; using System. web; namespace NuctechEquipment. layouts. nuctechEquipment. appCore. httpModules {public class ReqestModule: IHttpModule {// initialization --- public void Init (HttpApplication context) that must be implemented {// event registration ---------- customize the method to register context. beginRequest + = new EventHandler (Application_BeginRequeset); context. endRequest + = new EventHandler (Application_EndRequeset);} // start request --- method of the custom rewrite start request and method of the end request public void Application_BeginRequeset (object sender, EventArgs arg) {} // end request public void Application_EndRequeset (object sender, EventArgs arg) {HttpApplication app = sender as HttpApplication; Console. writeLine (app. request. filePath); if (app. request. filePath. contains (". aspx ") = false) {}} // release --- public void Dispose () {}} that must be implemented (){}}}
Then, configure it under the <modules runAllManagedModulesForAllRequests = "true"> node of webconfig under iis 80.
<Add name = "ReqestModule" type = "NuctechEquipment. Layouts. NuctechEquipment. AppCore. HttpModules. ReqestModule, NuctechEquipment"/>
-- The name is the same as the class name.
-- Before the type comma, the dll name of the class after the namespace + class comma
Finally, put the dll in the bin directory on the iis 80 website.