上一篇講了從創(chuàng)建應(yīng)用程序域到創(chuàng)建ISAPIRuntime實例的過程,本篇繼續(xù)講Asp.net處理第一次請求的必要的初始化過程。
ISAPIRuntime分析
ISAPIRuntime在System.Web.Hosting中實現(xiàn),它的ProcessRequest是我們處理web請求的入口。
public int ProcessRequest(IntPtr ecb, int iWRType) { IntPtr pHttpCompletion = IntPtr.Zero; if (iWRType == WORKER_REQUEST_TYPE_IN_PROC_VERSION_2) { pHttpCompletion = ecb; ecb = UnsafeNativeMethods.GetEcb(pHttpCompletion); } ISAPIWorkerRequest wr = null; try { bool useOOP = (iWRType == WORKER_REQUEST_TYPE_OOP); wr = ISAPIWorkerRequest.CreateWorkerRequest(ecb, useOOP); wr.Initialize(); String wrPath = wr.GetAppPathTranslated(); String adPath = HttpRuntime.AppDomainAppPathInternal; if (adPath == null ||StringUtil.EqualsIgnoreCase(wrPath, adPath)) {