zoukankan      html  css  js  c++  java
  • Aspx页面的相关流程和事件

    参考资料:

    Msdn:

    HTTP Handlers and HTTP Modules Overview:

    ms-help://MS.MSDNQTR.v90.en/dv_vwdcon/html/f540bdeb-d22e-4e1d-ba8a-fe6c9926283b.htm

    ASP.NET Application Life Cycle Overview for IIS 7.0

    ms-help://MS.MSDNQTR.v90.en/dv_vwdcon/html/be3378e2-7071-48d4-9d6f-1b31d73bc7aa.htm

    OnLoadPage_Load的差异分析

    http://www.cnblogs.com/jintianhu/archive/2010/12/10/1902078.html

    .NET (C#) Internals: ASP.NET 应用程序与页面生命周期(意译)

    http://www.cnblogs.com/skynet/archive/2010/04/29/1724020.html

    Community Server专题四:HttpHandler:

    http://www.cnblogs.com/ugoer/archive/2005/09/07/231676.html

    Aspx页面继承了:Page

    Page类的信息:public class Page : TemplateControl, IHttpHandler

    interface IHttpHandler

    {

    void ProcessRequest(HttpContext ctx);

    bool IsReuseable  { get; }

    }

    接口中ProcessRequest是添加自己的代码进行相应处理的地方。IsReuseable属性指明该HttpHandler的实现类是否需要缓存。

    说明:1,Page类是一个httphandler,那么肯定实现了ProcessRequest方法;该方法将处理对aspx页面的请求

          2,继承了TemplateControl,从名字可以看出该类的作用是模板,反编译查看源码发现了如下常用方法的字符串形式

    private const string _onTransactionAbortEventName = "OnTransactionAbort";

        private const string _onTransactionCommitEventName = "OnTransactionCommit";

        private const string _pageAbortTransactionEventName = "Page_AbortTransaction";

        private const string _pageCommitTransactionEventName = "Page_CommitTransaction";

        private const string _pageDataBindEventName = "Page_DataBind";

        private const string _pageErrorEventName = "Page_Error";

        private const string _pageInitCompleteEventName = "Page_InitComplete";

        private const string _pageInitEventName = "Page_Init";

        private const string _pageLoadCompleteEventName = "Page_LoadComplete";

        private const string _pageLoadEventName = "Page_Load";

        private const string _pagePreInitEventName = "Page_PreInit";

        private const string _pagePreLoadEventName = "Page_PreLoad";

        private const string _pagePreRenderCompleteEventName = "Page_PreRenderComplete";

        private const string _pagePreRenderEventName = "Page_PreRender";

        private const string _pageSaveStateCompleteEventName = "Page_SaveStateComplete";

    private const string _pageUnloadEventName = "Page_Unload";

    从这些字符串中可以猜测aspx页面的常用事件的执行和这个类有一点的关系

    Machine.Config :

    Httphandler配置节

    <add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory"/>

    反编译查看源码:

    PageHandlerFactory的GetHandler初始化实现了IHttpHandler的页面,继承了Page的页面都是满足该要求

       private IHttpHandler GetHandlerHelper(HttpContext context, string requestType, VirtualPath virtualPath, string physicalPath)
        {
            Page page = BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page), context, true, true) as Page;
            if (page == null)
            {
                return null;
            }
            page.TemplateControlVirtualPath = virtualPath;
            return page;
        }

    Page类中有关ProcessRequest的方法

    public virtual void ProcessRequest(HttpContext context)——》private void ProcessRequestWithNoAssert(HttpContext context)——》
    private void ProcessRequest()——》private void ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint)

    ——》private void ProcessRequestMain(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint)(在该方法中可以看到页面生命周期的相关事件的执行)

  • 相关阅读:
    一个爬虫的练习(妹子图)
    安装模块出现的编译问题(解决)
    基于套接字通信的简单练习(FTP)
    Python3 之选课系统
    数据爬取后台(PHP+Python)联合作战
    让pip 使用国内镜像源
    为啥学蛇和python10年后的变化
    模拟登陆百度以及Selenium 的基本用法
    冒泡排序及其效率分析(无聊搞来玩玩)
    LLVM编译器
  • 原文地址:https://www.cnblogs.com/webJingGao/p/2972822.html
Copyright © 2011-2022 走看看