Hi,
I get an exception in Authorization module which i am handling in Application_Error handler (also i am calling Server.ClearError()) since i want to sent custom error page with some error info to user.
I am surprised to see that final response sent to user have error response + response which was actually requested (which means that MVCHandler is processed)
I am posting below code snippet to simulate similar scenario for quick reference.
public MvcApplication()
{
AuthorizeRequest += (sender, arg) =>
{
throw new Exception("Boooommmm");
};
Error += (sender, arg) =>
{
HandleException();
};
}
private void HandleException()
{
var ex = Server.GetLastError();
Context.Response.Write(String.Format("Some Error Correlation ID to User"));
Server.ClearError();
}
And lets say : my HomeController action return simple text like :
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return Content("Some text from controller");
}
}
If I will run above application and hit /Home/Index, response I will get like :
"Some Error Correlation ID to User Some text from controller"
This made me to ask question :
Does HttpRuntime continue firing ApplicationEvents in sequence event after exception occurred in one of the event handler ?
I would like to understand how exception flows in such case (at least glimpse of this would be helpful)
Thanks in advance!!
Rahul