上面兩篇文章說了http協(xié)議和IIS處理,這次說下當(dāng)IIS把請求交給Asp.net后的過程。
AppManagerAppDomainFactory
當(dāng)IIS把請求交給asp.net時候,如果AppDomain還不存在則創(chuàng)建APPDomain,將AppDomain指派給與請求對應(yīng)的應(yīng)用程序,這通過AppManagerAppDomainFactory類中的Create方法實現(xiàn),代碼如下:
public Object Create(String appId, String appPath) { try { if (appPath[0] == '.') { System.IO.FileInfo file = new System.IO.FileInfo(appPath); appPath = file.FullName; } if (!StringUtil.StringEndsWith(appPath, '\\')) { appPath = appPath + "\\"; } ... ISAPIApplicationHost appHost = new ISAPIApplicationHost(appId, appPath,false); //創(chuàng)建環(huán)境,包括編譯環(huán)境 ISAPIRuntime isapiRuntime = (ISAPIRuntime)_appManager.CreateObjectInternal(appId, typeof(ISAPIRuntime), appHost, false, null); isapiRuntime.StartProcessing(); return new ObjectHandle(isapiRuntime); } catch (Exception e) { &n