IIS6服务器的请求流程(图文&源码)

本文介绍了IIS7的开发与管理方法,并详细解析了托管程序的入口方法及ASP.NET页面的具体执行过程。通过具体代码展示了ISAPIWorkerRequest的创建与初始化,以及页面路径变化时的处理方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.IIS 7开发与管理完全参考手册  http://book.51cto.com/art/200908/146040.htm
2.Web服务IIS 6   https://technet.microsoft.com/zh-cn/library/2005.05.servingtheweb(en-us).aspx

3.简单流程图

 

 

 

 

 

 4.这个就是处理 【托管程序】的入口方法了  
 1 [SecurityPermission(SecurityAction.LinkDemand, Unrestricted=true)]
 2 public int ProcessRequest(IntPtr ecb, int iWRType){
 3     IntPtr zero = IntPtr.Zero;
 4     if ( iWRType == 2 ){zero = ecb;ecb = UnsafeNativeMethods.GetEcb(zero);}
 5     ISAPIWorkerRequest wr = null; //ISAPIWorkerRequest : HttpWorkerRequest
 6     try{
 7         bool useOOP = iWRType == 1;
 8         wr = ISAPIWorkerRequest.CreateWorkerRequest(ecb, useOOP);//将 ecb 句柄封装成 HttpWorkerRequest 的 源码在此 !!!
 9         wr.Initialize();
10         string appPathTranslated = wr.GetAppPathTranslated();
11         string appDomainAppPathInternal = HttpRuntime.AppDomainAppPathInternal;
12 
13         if ((appDomainAppPathInternal == null) || StringUtil.EqualsIgnoreCase(appPathTranslated, appDomainAppPathInternal))
14         {
15             HttpRuntime.ProcessRequestNoDemand(wr);
16             return 0;
17         }
18 
19         object[] args = new object[] { appDomainAppPathInternal, appPathTranslated };
20         HttpRuntime.ShutdownAppDomain(ApplicationShutdownReason.PhysicalApplicationPathChanged, SR.GetString("Hosting_Phys_Path_Changed", args));
21         return 1;
22     }catch (Exception exception){
23         try{ WebBaseEvent.RaiseRuntimeError(exception, this); }catch{}
24         if ( (wr == null) || !(wr.Ecb == IntPtr.Zero) ){throw;}
25         if ( zero != IntPtr.Zero ){UnsafeNativeMethods.SetDoneWithSessionCalled(zero);}
26         if ( exception is ThreadAbortException ){Thread.ResetAbort();}
27         return 0;
28     }
29 }
5.aspx页面的执行过程,可以在页面加入<%@ Page Language="C#"  Trace="true" %> aspx页面执行流程会在浏览器中显示

 

转载于:https://www.cnblogs.com/techliang666/p/8004174.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值