While debugging my MVC 4 application in VS2010 SP1, the Application_Error()
handler was invoked but Server.GetLastError()
was null.
protected void Application_Error()
{
var exception = Server.GetLastError();
// exception is null. How is that possible?
}
MSDN states Application_Error
is
called if an unhandled exception occurs anywhere in your ... application... You can get information about the most recent error from the
GetLastError
method.
The MSDN docs for Server.GetLastError
() states
Return value: The previous exception that was thrown.
How can I possibly be in a state where Application_Error()
was called but Server.GetLastError()
returns null?