为什么我的异常处理程序不在Sitecore.mvc.Pipelines中触发?

时间:2016-06-01 20:19:22

标签: c# sitecore sitecore-mvc

我正在尝试为我们的公共站点创建一个很好的异常消息,因此我通过修改我的Sitecore.Pipelines配置文件来覆盖“Sitecore.Mvc.Pipelines.MvcEvents.Exceptions.ShowAspNetErrorMessage”,如此

namespace Northwestern.Core.Infrastructure.Pipelines
{
    public class ExceptionErrorHandler : ExceptionProcessor
    {
        public override void Process(ExceptionArgs args)
        {
            var context = args.ExceptionContext;
            var httpContext = context.HttpContext;
            var exception = context.Exception;

            // Return a 500 status code and execute the custom error page.
            httpContext.Server.ClearError();
            httpContext.Response.StatusCode = 500;
            httpContext.Server.Execute("/Error-Page");
        }

    }
}

这是我的ExceptionErrorHandler代码:

#/usr/bin/env python2.7
import subprocess
# Do something with analytics
# ...
# Now call docxfactory script
subprocess.call(['python3', 'docxcript.py'])

但是,我在上面的代码中放置了一个断点,它永远不会碰到我的断点

1 个答案:

答案 0 :(得分:1)

尝试添加如下管道:

  <pipelines>
      <mvc.exception>
        <processor type="Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage, Sitecore.Mvc">
          <patch:attribute name="type">Northwestern.Core.Infrastructure.Pipelines.ExceptionErrorHandler, Northwestern.Core</patch:attribute>
        </processor>
      </mvc.exception>
    </pipelines>