In Global.asax we have a class of type System.Web.HttpApplication named MvcApplication that represents the application and in which we can handle various events.
I'm interested in the Application_Error handler. In this handler we can use all the properties of the class MvcApplication.
-1-
Is always true that '(MvcApplication)sender' and 'this' are the same object?
protected void Application_Error(object sender, EventArgs e)
{
var httpApp = (MvcApplication)sender;
var equality1 = httpApp == this; // always true?
}
-2-
What is the best way to get the error? The following examples return the same error?
Exception ex0 = this.Context.Error;
Exception ex1 = httpContext.Error;
Exception ex2 = Server.GetLastError();
var equality3 = ex1 == ex2; // true?