This article is well written and recommended.
Bodhi non-tree
Http://www.cnblogs.com/heroman/archive/2005/05/12/153975.html
The operating mode of the entire ASP. NET application is analyzed.
For loading httpmodule, I think it is
Load firstHttpmodule
Then loadHttphandler
Finally, load the globalGlobal
This is what Scott gave when he introduced urlwrite.
II:
Currently, a timer is used in a program that defines a class to implement the httpmodule interface.
Through this implementation, I found some misunderstandings about the Asp.net running mode.
To complete the class of the httpmodule interface, you must complete the following methods:
1 Public void Init (system. Web. httpapplication context );
2 Public void dispose ();
Here is a question: is it the init method of httpmodule every time?
Answer:No
If you define some methods in init and expect them to run in each user request, the results will be disappointing.
I initialized a static Timer In the init method and expected it to complete some work at a scheduled time. It was found that the program only ran this method during the initial operation, when the user requests again, the code in init will not run.
Therefore, the conclusion is:
The class that completes the httpmodule is only responsible for passing in the system. Web. httpapplication context and requiring the user to define the context event,
For example:
Beginrequest ....
What the user wants to doThe task is to define the method after the httpapplication object event Delegate is completed.
Once the event is linked, user requests are processed each time.
So here I have a question:
If I instantiate a static timer in a beginrequest event in an httpmodule,
So, can this timer always run? (the premise is that IIS is not restarted and no exception occurs ).