Hi
I am using ELMAH to handle expception in my MVC project. All is working fine, except for when the request is an ajax request.
The exception is captured and logged but when I do a response.redirect to the error page, the redirect doesn't happen and the error message is displayed on the same page, overlapping the existing content.
Here is the code :
this is the elmah code to catch exceptions. I assign the value "Y" if it's an Ajax request
if (context.HttpContext.Request.IsAjaxRequest())
{
context.HttpContext.Session["IsAjax"] = "Y";
}
var e = context.Exception;
if (!context.ExceptionHandled
|| RaiseErrorSignal(e)
|| IsFiltered(context))
return;
LogException(e);
And in my Global asax file
In the ErrorLog_Logged method I store the GUID returned from ELMAH in a session variable to later display the id to the user so they can mail the GUID and I can see the exception quering the GUID against the appropriate elmah table in the database.
protected void ErrorLog_Logged(object sender, ErrorLoggedEventArgs args)
{
var id = args.Entry.Id;
Session["ErrorId"] = id.ToString();
}
and in the application_Error method I do the following
protected void Application_Error( object sender, EventArgs e )
{
Response.Redirect("/Error/Index");
}
What am I doing wrong. The redirect doesn't work and the error message is displayed on top of the existing page.
My existing page has a bunch of jquery tabs.
I really can't get my head around this. If anyone knows the answer, I will greatly apprecite it.
Please help.
Thanks in advance.