zoukankan      html  css  js  c++  java
  • Text请求处理过程

    Text请求处理过程: (原文引自-dudu-  查看原文 )

    请求被分成三种:*.asmx、Error.aspx、其他
    1. *.asmx被System.Web.Services.Protocols.WebServiceHandlerFactory处理
    2. Error.aspx被System.Web.UI.PageHandlerFactory
    3. 其他都被Dottext.Common.UrlManager.UrlReWriteHandlerFactory
    所以研究.Text的请求处理过程,关键是理解Dottext.Common.UrlManager.UrlReWriteHandlerFactory如何处理请求的?
    Dottext.Common.UrlManager.UrlReWriteHandlerFactory实现了IHttpHandlerFactory接口,该接口只有两个成员GetHandler(返回实现 IHttpHandler 接口的类的实例),ReleaseHandler(使工厂可以重用现有的处理程序实例)。.Text中是如何根据不同的请求得到不同的HttpHandler?所有有关HttpHandler的配置信息都放在web.config的<HandlerConfiguration>中。<HandlerConfiguration>被返序列化产生Dottext.Common.UrlManager.HandlerConfiguration的实例。通过Dottext.Common.UrlManager.HandlerConfiguration的属性HttpHandlers就可以得到所有的HttpHandler。在UrlReWriteHandlerFactory.GetHandler中,通过正则表达式,获得不同请求的HttpHandler。这里的HttpHandler实际上是Dottext.Common.UrlManager.HttpHandler类的实例。HttpHandler有个属性HandlerType,HandlerType是enum变量,UrlReWriteHandlerFactory根据HandlerType来对不同的请求进行处理。HandlerType有三个值Page、Direct、Factory。
     
    现在,我们以Page类型(也是默认类型)为例,说明一下具体的处理过程:
    对于Page类型,由UrlReWriteHandlerFactory.ProccessHandlerTypePage()处理,在ProccessHandlerTypePage中,先得到FullPageLocation,在web.config中可以配置,默认是DTP.aspx,然后调用HandlerConfiguration.SetControls(它只一行处理语句:context.Items.Add("Dottext.Common.UrlManager.ControlContext",controls);),context.Items是IHttpModule 和 IHttpHandler 之间共享数据区。这里我的理解是:将需要显示哪些controls的配置信息存储在context.Items中,以便在后来的处理中从context.Items读取(实际上是在DottextMasterPage中读取并显示controls的,这就是.Text中动态加载ASC控件的原理)。最后,通过PageParser.GetCompiledPageInstance(url,pagepath,context);返回一个HttpHandler,该方法的功能我的理解是为url请求创建一个pagepath的实例,类似于Response.Redirect。
  • 相关阅读:
    Generator函数介绍
    C语言基础三
    C语言基础二
    C语言基础一
    node——路由控制
    Node.js_HTTP模块
    node_Express安装及检验
    conda Pyhon版本切换
    JAVA泛型里面各值代表的意义
    jq实现表格多行列复制
  • 原文地址:https://www.cnblogs.com/toney/p/62537.html
Copyright © 2011-2022 走看看