本篇主要講述MVC處理請(qǐng)求時(shí)創(chuàng)建Controller和執(zhí)行Action的完整過(guò)程。
創(chuàng)建Controller
先查看MvcHandler中處理請(qǐng)求的方法BeginProcessRequest:
protected internal virtual IAsyncResult BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, object state) { IController controller; IControllerFactory factory; ProcessRequestInit(httpContext, out controller, out factory); IAsyncController asyncController = controller as IAsyncController; if (asyncController != null) { …… } else { …… } }