C# 在哪里可以看到ASP.NET中事件是如何连接的

C# 在哪里可以看到ASP.NET中事件是如何连接的,c#,asp.net,events,autoeventwireup,C#,Asp.net,Events,Autoeventwireup,我的面条有一种感觉的火花。我正在浏览我的ASP.NET页面,我注意到 等等,Page_Load不等于类的名称,因此它不能是aspx.cs页面上我的类的构造函数 我有一种直觉,即AutoEventWireup=“true”负责告诉页面在默认情况下调用protectedvoidpage\u Load(objectsender,EventArgs e)方法。问题是,我不知道如何或在何处查看哪些事件连接到哪些处理程序。我确信AutoEventWireup=“true”的某个地方有这个片段: this.L

我的面条有一种感觉的火花。我正在浏览我的ASP.NET页面,我注意到

等等,Page_Load不等于类的名称,因此它不能是aspx.cs页面上我的类的构造函数

我有一种直觉,即
AutoEventWireup=“true”
负责告诉页面在默认情况下调用
protectedvoidpage\u Load(objectsender,EventArgs e)
方法。问题是,我不知道如何或在何处查看哪些事件连接到哪些处理程序。我确信
AutoEventWireup=“true”
的某个地方有这个片段:

this.Load += this.Page_Load
我只是想扩大我在这方面的知识。在哪里可以看到AutoEventWireup正在“连接”哪些事件

编辑


我是在尝试调用虚拟构造函数后发现这个想法的(由于我不小心删除了
Page\u Load
,我在我的代码中创建了一个构造函数。Resharper建议我必须密封该类。我认为这是一种不寻常的行为。我仔细检查了另一个页面,然后复制粘贴了我的
Page\u Load
。这就是我想知道事件是如何连接起来的。ASP.NET怎么知道它必须ll
Page\u Load

这是针对.NET 4的,其他框架可能略有不同,但通过Reflector,您可以发现
TemplateControl
哪个
Page
UserControl
都有一个私有方法
GetDelegateInformationWithNoAssert
,用于连接这些委托

private void GetDelegateInformationWithNoAssert(IDictionary dictionary)
{
    if (this is Page)
    {
        this.GetDelegateInformationFromMethod("Page_PreInit", dictionary);
        this.GetDelegateInformationFromMethod("Page_PreLoad", dictionary);
        this.GetDelegateInformationFromMethod("Page_LoadComplete", dictionary);
        this.GetDelegateInformationFromMethod("Page_PreRenderComplete", dictionary);
        this.GetDelegateInformationFromMethod("Page_InitComplete", dictionary);
        this.GetDelegateInformationFromMethod("Page_SaveStateComplete", dictionary);
    }
    this.GetDelegateInformationFromMethod("Page_Init", dictionary);
    this.GetDelegateInformationFromMethod("Page_Load", dictionary);
    this.GetDelegateInformationFromMethod("Page_DataBind", dictionary);
    this.GetDelegateInformationFromMethod("Page_PreRender", dictionary);
    this.GetDelegateInformationFromMethod("Page_Unload", dictionary);
    this.GetDelegateInformationFromMethod("Page_Error", dictionary);
    if (!this.GetDelegateInformationFromMethod("Page_AbortTransaction", dictionary))
    {
        this.GetDelegateInformationFromMethod("OnTransactionAbort", dictionary);
    }
    if (!this.GetDelegateInformationFromMethod("Page_CommitTransaction", dictionary))
    {
        this.GetDelegateInformationFromMethod("OnTransactionCommit", dictionary);
    }
}

如果您遵循此方法的用法,您将看到它是从
hookupautomaticcandler
调用的,并且此方法仅在
SupportAutoEvents
为真时才附加代理。

天哪,您在这方面付出了很多努力。这一代码部分我看到了我想要看到的内容。AutoEventWireup是你可以为它分配的处理程序非常有限。你应该得到这个