1. Application_Error in Global.asax.cs
protected void Application_Error(object sender, EventArgs e)
{
HttpContext.Current.Response …
HttpContext.Current.Response.StatusCode ….
System.Net.HttpStatusCode.InternalServerError ….
// For custom error page you can do
something like this
var errorPageUrl =
GetGeneralErrorPage();
HttpContext.Current.Server.TransferRequest(errorPageUrl);
}
2. Pipeline
Try
this.
- Create a class to catch
and log exceptions. Something like this
public
class HandleMvcException : ExceptionProcessor
{
public override void
Process(ExceptionArgs args)
{
var context =
args.ExceptionContext;
var httpContext =
context.HttpContext;
var exception = context.Exception;
if (context.ExceptionHandled ||
httpContext == null || exception == null)
{
return;
}
httpContext.Request.Url…
exception.Source…
exception.Message…
exception.StackTrace…
}
}
- See if you can find
where the exception handling pipeline is with Sitecore and replace a
Sitecore processor with yours via a config patch file.
<pipelines>
<mvc.exception>
<processor
type="Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage,
Sitecore.Mvc">
<patch:attribute
name="type">Igt.Pipelines.HandleMvcException, Igt</patch:attribute>
</processor>
</mvc.exception>
</pipelines>
Thanks!
No comments:
Post a Comment