Microsoft.Owin.Diagnostics.ErrorPageExtensions.UserErrorPage将捕获哪些异常

时间:2013-11-25 15:56:42

标签: owin katana

我从http://blogs.msdn.com/b/webdev/archive/2013/11/22/debugging-owin-app-or-framework.aspx获得了演示代码,它显示了一个性感的错误页面。

app.UseErrorPage(new ErrorPageOptions()
        {
            //Shows the OWIN environment dictionary keys and values. This detail is enabled by default if you are running your app from VS unless disabled in code. 
            ShowEnvironment = true,
            //Hides cookie details
            ShowCookies = false, 
            //Shows the lines of code throwing this exception. This detail is enabled by default if you are running your app from VS unless disabled in code. 
 ShowSourceCode = true,
            });

            app.Run(async context =>
            {
               throw new Exception("UseErrorPage() demo");
               await context.Response.WriteAsync("Error page demo");
            });
        }

但是,如果我在Controller动作中抛出异常,则不会显示错误页面,我仍然会看到YSOD。

所以我想知道UseErrorPage会捕获哪些异常?我是否需要其他配置才能使其正常工作?

1 个答案:

答案 0 :(得分:8)

通过Controller操作你的意思是MVC? MVC不直接在OWIN上运行,因此Asp.Net首先看到异常并向您显示YSOD。 Katana ErrorPage只能显示OWIN管道中发生的异常。