aspnet源码解析(一)

aspnet源码解析(一)

ID:30775854

大小:87.00 KB

页数:8页

时间:2019-01-03

aspnet源码解析(一)_第1页
aspnet源码解析(一)_第2页
aspnet源码解析(一)_第3页
aspnet源码解析(一)_第4页
aspnet源码解析(一)_第5页
资源描述:

《aspnet源码解析(一)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、Asp.Net源码解析(一)上面两篇文章说了http协议和IIS处理,这次说下当IIS把请求交给Asp.net后的过程。AppManagerAppDomainFactory当IIS把请求交给asp.net时候,如果AppDomain还不存在则创建APPDomain,将AppDomain指派给与请求对应的应用程序,这通过AppManagerAppDomainFactory类屮的Create丿了法实现,代码如下:publicObjectCreate(Stringappld,StringappPath){try{讦(appPath[O]=={Syste

2、m.10.Fileinfofile=newSystem.10.Filelnfo(appPath);appPath=file.FullName;}if(IStringUtil.StringEndsWithfappPath,'\')){appPath=appPath+";ISAPIApplicationHostappHost=newISAPIApplicationHost(appld,appPath,false);〃创建环境,包括编译环境ISAPIRuntimeisapiRuntime=(ISAPIRuntime)_appManager.Cr

3、eateObjectlnternal(appld,typeof(ISAPIRuntime),appHost,false,null);isapiRuntime.StartProcessing();returnnewObjectHandle(isapiRuntime);}catch(Exceptione){•••}}创建完成后,非托管代码开始调用ISAPIRuntime中ProcessRequest方法(通过COM调用)ISAPIRuntime-asp.net入口首先看下ISAPIRuntime中的ProcessRequest方法签名publicin

4、tProcessRequest(lntPtrecb,intiWRType);ProcessRequest有两个参数,一个是请求报文的ecb句柄,一个请求的类型,在运行的过程中,ecb首先被再次封装成托管资源的请求报文wro把封装好的代码传递给HttpRuntime类中的ProcessRequestNoDemand.核心代码如下:booluseOOP=(iWRType==WORKER_REQUEST_TYPE_OOP);wr=ISAPIWorkerRequest.CreateWorkerRequest(ecb,useOOP);wr.lnitiali

5、ze();//checkifapppathmatches(needtorestartappdomain?)StringwrPath=wr.GetAppPathTranslated();StringadPath=HttpRuntime.AppDomainAppPathlnternal;讦(adPath==null11StringUtil.EqualsIgnoreCasefwrPath,adPath)){HttpRuntime.ProcessRequestNoDemand(wr);return0;}else{//needtorestartappdom

6、ainHttpRuntime.ShutdownAppDomain(ApplicationShutdownReason.PhysicalApplicationPathChanged,SR.GetString(SR.Hosting_Phys_Path_Changed/adPath,wrPath));return1;}HttpRuntimeHttpRuntime收到传递过来的HttpWorkerRequest类的实例对象wr,通过调用当前类屮的ProcessRequestNow方法,把参数传递给ProcessRequestlnternal(Proces

7、sRequestNow的调用ProcessRequestlnternal)。internalstaticvoidProcessRequestNoDemand(HttpWorkerRequestwr){RequestQueuerq=_theRuntime._requestQueue;wr.UpdatelnitialCounters();if(rq!=null)//couldbenullbeforefirstrequestwr=rq.GetRequestToExecute(wr);if(wr!=null){CalculateWaitTimeAndU

8、pdatePerfCounter(wr);wr.ResetStartTime();ProcessRequestNow(wr);}}int

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。