ASP. NET life Cycle Series One

Source: Internet
Author: User

The ASP. NET life cycle for primary and even intermediate programmers, has always been a problem, many programmers do not understand the life cycle, resulting in the use of ASP. I feel very inflexible, feel too many things by the Microsoft package, we can not change, in fact, as long as you know a little bit, it is not like this!

I write this series of articles is the use of the total score, first let everyone understand, and then one by one breakthrough. First a story, also seen in the Garden (http://www.cnblogs.com/GodSpeed/archive/2010/06/19/1761095.html), I think this write some of the details of the mistakes, slightly add their own ideas and understanding , if there are errors, please leave a message!

When you visit the blog Park to see my article, this request was received by the blog Park Web SERVER (IIS) "is actually intercepted by a process called Inetinfo.exe in IIS." Blog Park IIS took a look at your request, "Oh, yes. aspx ah, to aspnet_isapi.dll to deal with it, I gave this request to Aspnet_isapi.dll, and said:" This you to deal with, you finished the HTML to me, I'll give the requestor a reply. "

Aspnet_isapi.dll didn't have time to complain when he received the request from IIS. How do you do that? In fact ah very simple, is through an HTTP pipeline pipeline to the Aspnet_wp.exe process, next to the. NETFramework httpruntime Processing Center, httpruntime It is actually doing a few things.

First, it first created a context object, it is like a box, the box is of course to install things, what?

Second, HttpRuntime creates a request object that contains all the information that IIS passes to it (the actual request that IIS passes over).

Thirdly, httpruntime then creates a response object, which is used for HTML and in the box (Context).

Four, then, HttpRuntime said, too tired, the job is not a job, or hire a person. I found HttpApplication. Factory a project Manager (HttpApplication object) and then handed the box to the project manager and said, here are the request we received, all you need to do is The inside of the reponse fill, specific how to do you weigh it, go.

The project manager (HttpApplication object) just want to, what kind of work I do money you take? No, I have to find two laborers, so I have: programmer HttpModule and programmer HttpHandler, let's call them P_module and P_handler bar, project manager first found P_module, and gave P_module big enough power, P_module (HttpModule) is very competent, it is able to see HttpRuntime to the project manager (HttpApplication object) of the box (Context), and according to the things inside to make some decisions, such as security AH (FormsAuthenticationModule), State AH (sessionstatemodule) and so on. After P_module's work was completed (perhaps it changed the contents of the box), he then handed over to his deputy P_handler to do the job of filling response. But Ah, want to find a suitable p_handle also difficult ah, looked for a long time also did not find, well, find headhunting (HttpHandler Factory) bar. A headhunter looked, "Oh, to. aspx Handler ah", so I found a natural good and willing to deal with the page P_handler, so P_module put his handled the box to it and said: "Deal with this box of things, and then handed me."

P_handler is a natural to deal with the page of the cattle, it according to the request object is the thing is used a trick "big move", do not know how moved, moved out of the HTML and stuffed into the response object. P_handler confidently smiled and returned the box to HttpModule. Then, another layer of the box to the top of the case to pass "can not leapfrog Ah, everyone has their own boss, can only give the box to their superior", finally passed to the Iis,iis and gave you, you see this article.

The story is the story, the story is the dead thing, is the past. There must have been a missing place in the past. So where are we missing this story?

First, the interaction between IIS and ASP is not as simple and straightforward as I said, and there are a lot of things going on in the middle.

Second, HttpModule, our programmer p_module, is actually capable of a lot of things, and we are not digging.

Third, HttpHandler, our programmer p_handler, it's "The big Thing" is ProcessRequest method, here is not detailed.

Fourth... I'll talk to you again when I think about it.

Hopefully this text will help you understand the net life cycle more easily, and I will continue to work hard to speak out ASP in the simplest and most straightforward way. NET principles and operating mechanisms. Welcome to shoot Bricks, thank you.

ASP. NET life Cycle Series One

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.