Asp.net Running Mechanism (httpmodule loading)

Source: Internet
Author: User

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 ).

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.