Global.asax - How is Application_Error called?

1k views Asked by At

Behind the scenes in ASP.NET applications how is the method Application_Error being called when an Exception occurs? Reflection? Delegate? I went looking for the code using a decompiler and did not easily see where this happens.

I know how the events are wired up in WinForms when the methods get inserted with underscores. But got curious how this works in ASP.NET and what design pattern is being used.

2

There are 2 answers

0
KnightFox On

You can refer to the msdn source for this https://msdn.microsoft.com/en-us/library/ms178473(v=vs.140).aspx

Application_Error can be raised at any phase in the application life cycle.

1
Ricardo Peres On

ASP.NET hooks automatically the HttpApplication.Error event to this method, if it exists.