Asp.Net page life-cycle - What tool ( perhaps Reflector?) would enable me to view the order in which page events and their event handlers are called

.net, asp.net, c#

Solution

ASP.net Tracing would be the one I'd go for. It'll show you when each method in your page/control is called and you can also output additional data to the trace as well. It's primarily intended (I guess!) as a debugging tool, but I think it'll be more than adequate to show you the exact lifecycle a page is undertaking.

To turn on tracing, add the following to your web.config file:

 <trace enabled="true" pageOutput="true" requestLimit="10" traceMode="SortByTime" localOnly="true" />

As Jim Schubert pointed out in a comment, you can also modify the @page directive of a specific page to enable tracing:

 <%@ Page Title="" Trace="true"......

You can then access the trace details by navigating to "Trace.axd". If you're using a remote server (i.e. not Cassini or IIS on localhost) then change the `localonly="true"` to `localonly="false"` in the snippet above.

Having an understanding of what goes on under the hood in WebForms can be very useful, it certainly makes solving some of the oddities and edge-cases a lot easier.

Problem

1) I know there are lots of web sites that describe in what order events are called during the Asp.Net page life-cycle. But is there also a tool, perhaps Reflector, that would enable me to figure out by myself in what order are ALL the page’s events and their event handlers called during the page’s life cycle? 2) Would you say that trying to figure out exactly what is going on under the hood is a good idea or a waste of time? To clarify – I’d like to figure out exactly what is going on when a control tree is build – thus all the method calls, all the events called etc needed for control tree to be build ( I imagine there are hundreds or perhaps thousands lines of code written just for building a control tree). thanx

Original source