The ihttpmodule. init method is interpreted on msdn as the event handling method that httpmodule registers to a specific event using the init method. This is also explained from the information I have seen: When httpapplication loads an httpmodule, it will call ihttpmodule. INIT () and use this opportunity to register the events it cares about. Then, the ihttpmodule. init method should perform initialization only once at application startup. So some of our initialization items can also be put here.
As a result, the ihttpmodule. init method is not executed only once. The ihttpmodule. init method is executed again when the framework page or the same page is submitted multiple times in a fast and consistent manner. So far, I still don't know why. I hope you can give me some advice.
I did a test example myself: Download the test code from here
The solution contains two projects: httpmodule and webapplication.
Use the following statement in the httpmodule. init method:
Httpcontext. Current. server. mappath ("Web. config ")
Provides the function of searching web. config files. If you start from the defalut. ASPX page in the root directory, the correct web. config path is obtained. When you jump to a page under a subdirectory, The httpmodule. init method cannot be executed. However, the httpmodule. init method is executed again on the subdirectory page. In this case, an incorrect web. config path is obtained.
Technorati: Init function httpmodule