7

I got the demo code from http://blogs.msdn.com/b/webdev/archive/2013/11/22/debugging-owin-app-or-framework.aspx , and it shows a sexy error page.

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");
            });
        }

However, if I throw a exception in a Controller action, the error page will not shown, and I still see the YSOD.

So I want to know what exceptions will be caught by UseErrorPage? Do I need additional configurations to make it works?

Jun Guo
  • 484
  • 1
  • 3
  • 14
  • 1
    Web API looks to be handling the exception and converting it in to a 500 response before the UseErroPage middleware can handle it. In general any unhandled responses in the pipeline are handled by UseErrorPage middleware. – Praburaj Nov 25 '13 at 22:51

1 Answers1

8

And by Controller action you mean MVC? MVC does not run directly on OWIN, so Asp.Net sees the exception first and shows you the YSOD. The Katana ErrorPage can only show you exceptions that happen in the OWIN pipeline.

Tratcher
  • 5,929
  • 34
  • 44