1

According to this answer it's up to me whether I declare an ASP.NET application event handler in Global.asax.cs like this (no parameters)

protected void Application_Error()

or like this (two parameters)

protected void Application_Error(object sender, EventArgs e)

so basically it boils down to whether I'm interested in those parameters. So far I see that e is a reference to EventArgs (not some descendant) and contains absolutely no data and sender is always a reference to ASP.global_asax type object that contains a reference to the class containing the handler (same as this) and a reference to an instance of System.Web.Profile.DefaultProfile type.

Other handlers also don't seem to ever have useful parameters passed to them. For example, Application_End() handler is always passed a reference to System.Web.HttpApplicationFactory and a reference to EventArgs.

So far I feel like I should just convert each of my Application_?(object sender, EventArgs e) handlers into just Application_?() form.

Is there ever a situation when those handler have useful (at least for debugging) parameters passed?

Community
  • 1
  • 1
sharptooth
  • 167,383
  • 100
  • 513
  • 979

0 Answers0