Skip to content

Instantly share code, notes, and snippets.

@geoffreysmith
Created November 1, 2013 14:48
Show Gist options
  • Save geoffreysmith/7266517 to your computer and use it in GitHub Desktop.
Save geoffreysmith/7266517 to your computer and use it in GitHub Desktop.

Revisions

  1. geoffreysmith created this gist Nov 1, 2013.
    19 changes: 19 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    protected void Application_Error(object sender, EventArgs e)
    {
    var exception = Server.GetLastError();
    Server.ClearError();

    var routeData = new RouteData();
    routeData.Values.Add("controller", "Error");
    routeData.Values.Add("action", "Index");

    Sitecore.Diagnostics.Log.Error("Application_Error invoked", exception, this);

    routeData.Values.Add("statusCode",
    exception.GetType() == typeof (HttpException)
    ? ((HttpException) exception).GetHttpCode()
    : 500);

    IController controller = new ErrorController();
    controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
    }