On the server side, determine the type of the file sent by the client , If it's a static file , Go straight back to , In the page output display . If it's a dynamic file , adopt aspnet_isapi.dll Transferred .NetFrameWork Framework implementation .

establish ISAPIruntime object , perform ISAPIruntime Object ProcessRequest() Method

ProcessRequest() The method can be seen as entering Asp.Net Entrance point .

ProcessRequest() Method :

According to the handle passed in ( The number of the request message ) Looking for resources , establish ISAPIWorkerRequest object wr, Encapsulate the content of the request message into wr in , Will be wr to HttpRuntime in .

ProcessRequestNoDemand() Method :

ProcessRequestNow() Method :

ProcessRequestInternal() Method :

establish HttpContext object , And then the request message wr It's all encapsulated in context in .

establish HttpApplication object , adopt HttpApplicationFactory() This factory class GetApplicationInstance Method to create , stay HttpApplication Create... In the pool , That is to operate in the stack , The lifetime of the pool is the same as that of the application .

GetApplicationInstance():

This is the creation HttpApplication Object's factory class GetApplicationInstance() The method in .

establish HttpApplication There are three key methods in the object .

The first method :EnsureInited():

Double lock this factory class , Check HttpApplicationFactory Is it initialized , This this It stands for HttpApplicationFactory This factory class . without , adopt this.Init() Method to initialize . First use this.GetApplicationFile() Ways to find global.asax File address , Get global.asax file . And then call this.CompileApplication() Method pair global.asax File for compilation , obtain theApplicationType This type .

Second method :EnsureAppStartCalled(context):

Get global.asax file , Call and make sure it is called only once when the program starts global In file Application_Start() Method . Get all the routing information .

Third way :GetNormalApplicationInstance(context):

establish HttpApplication object , After successful creation, call InitInternal() Method to initialize . Read all the information in the configuration file for module Configuration content . Get the system definition module And the programmer's own definition of module, Save to HttpModuleCollection Collection , Then traverse the read HttpModuleCollection aggregate .

establish HttpApplication Then go into the request pipeline .

Initializing HttpApplication When , You can get system definitions and programmer definitions module.

Look at the system defined module:UrlRoutingModule

find Init() initialization module Methods

UrlRoutingModule.Init() Method :

Initialization module , take OnApplicationPostResolveRequestCache This event is registered in the seventh event of the pipeline , Execute this method when you get to the seventh event in the request pipeline .

OnApplicationPostResolveRequestCache() Method :

HttpApplication Object to trigger this event ,sender Represents the source of the event . All can be sender Turn into HttpApplication.

HttpContextBase Class is an abstract class , The class contains members that are associated with  HttpContext  Similar classes . Use  HttpContextBase Class can create some derived classes , These derived classes are related to  HttpContext  Kind of similar , But it can be customized and in  ASP.NET  External use of pipes .

use HttpContextBase Create context objects context.

Encapsulate the request further into context In the object .

perform PostResolveRequestCache(context) Method .

PostResolveRequestCache() Method :

Matching routing  HTTP  request , Retrieve the handler for the route , And set the handler to the current requested  HTTP  The handler .

The obtained routing rules and encapsulated context To match the request message in , Return routing data .

Get the object of the routing request  , Some methods in the message and so on , Determine whether it is null

If the route data is not empty, it means that the match is successful , Get the attributes of the routing data .

Encapsulate the request message , Return an instance , use IHttpHandler object httpHandler receive .

there httpHandler Namely MVCHandler,MVC Source code MVCHandler This class inherits IHttpAsyncHandler, IHttpHandler, IRequiresSessionState

Finally, map the current request to HttpHandler On .

MVC Request process Simple analysis ( One ) More articles about

  1. struts2 Request process source code analysis

    struts2 Request process source code analysis Struts2 yes Struts Communities and WebWork The common fruit of the community . We can even say ,Struts2 yes WebWork Upgraded version . What he used was WebWork At the heart of , therefore .Str ...

  2. mvc Summary of the request process

    Preface I've been thinking about a problem recently , My main way of learning is to read blogs to learn new things , But just look , I haven't summarized it , So there are always problems like this , I know a certain knowledge point , But it just can't be expressed very well , Very simple things often don't know how to be short and precise ...

  3. spring mvc Request process

    spring mvc Process request 1.     First the client sends one HTTP request ,Web The server receives the request , If the match DispatcherServlet Request mapping path for ,web The container forwards the request to Dispatch ...

  4. mini-uboot Simple analysis of the startup process

    Single chip microcomputer has the smallest system , The so-called minimum system , It's the least peripheral that SCM can work normally . about Uboot Come on , There's also a minimal system , because Uboot The main function is to boot the kernel . Let's go through a simple Mini-Uboot To analyze Ub ...

  5. user HTTP Simple analysis of the request process

    user terminal ( Like a computer browser ) Initiate a url request , Such as http://www.baidu.com/1.jpg. 1. The first thing the computer does is to www.baidu.com To parse the request , Get the server corresponding to the domain name IP. 2. Computer to service ...

  6. Asp.net Mvc How the request arrived MvcHandler Of ——UrlRoutingModule、MvcRouteHandler analysis , And make a wheel

    This is reproduced from :http://www.cnblogs.com/keyindex/archive/2012/08/11/2634005.html( That one is easier to forget , I hope the blogger doesn't get angry ) Preface This paper assumes that the reader ...

  7. spring MVC Processing request process and configuration details

    This paper mainly combs Spring MVC Handle http Process of request , As well as the configuration servlet And business application Common tags needed , And the meaning it contains . spring MVC Process request Let's start with a general picture In short ...

  8. spring MVC Process request

    spring MVC Process request Let's start with a general picture Let's talk about the steps : handlerMapping handlerMapping Map request to processor , That is... In the picture HandlerExecutionChain. ...

  9. Asp.Net MVC Request principle analysis

    analysis Asp.Net MVC Request process for , Let's look at it from the following aspects : To configure :IIS The configuration of the website can be divided into two parts : overall situation Web.Config And this site Web.Config . Asp.Net Routing It belongs to the overall situation ...

Random recommendation

  1. IE8/9 Local preview upload image

    Local preview means , Don't upload the image to the server after selecting it , But by a <img> Tag to preview local images , Not IE8/9 The browser can be accessed from <input type="file"/&g ...

  2. PHP Constant of basic knowledge

    Definition : define("FOO",     "something");

  3. word20161130

    1. even even numbers [ǒu shù][ The dictionary ] even; [ Count ] even number;[ example sentence ] In this case ,slot A There's an odd number of arrays in ,slot B There are even arrays in .In this example, ...

  4. UML3

    stay UML There are three main models in system development : Functional model : Show the functions of the system from the perspective of users , Include use case diagrams . The object model : Object of adoption , attribute , operation , Concepts such as relevance show the structure and foundation of the system , Including class diagrams . dynamic model : Show the internal behavior of the system ...

  5. Revit Secondary development ( Two ) An inclined board

    stay Revit In the process of secondary development , Building an inclined plate can be done as follows : // // Abstract : // Creates a slab within the project with the given ho ...

  6. SpringMVC The controller can't receive PUT Solutions for submitted parameters

    Abstract : SpringMVC The controller can't receive PUT Solutions for submitted parameters This time, the framework has been transformed , Put the controller's API All REST turn , Don't do it, don't know ,SpringMVC Of REST There are all kinds of pits for you to jump , It took me a lot of time to get around them ...

  7. The first 2 Homework -- be familiar with JUnit test

    2.1 Mooctest Use experience Mooctest Very convenient , You can evaluate your own test code in real time , Get coverage and reporting , You don't need to install the configuration environment yourself And the environment for installing and configuring plug-ins is very simple , You can focus on the test itself 2.2 Juni ...

  8. git Basic operation command

    1. git status see git state 2.git init 3.git push -u origin master Submit 4.git remote set " Email address i" ...

  9. [Go] Http package Brief introduction

    The structure of the request HTTP In response mode of request and response .Go  We've seen it for a long time ,handler The second parameter of the function http.Requests. Its structure is : type Request struct { M ...

  10. gnuplot Generate gif Animation

    Recently, a task needs to generate a dynamic graph , And then all of a sudden gnuplot It can generate gif Animation , It's really the right blog Gnuplot surprising Subheading of : I always tell myself: &q ...