Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What kind of exceptions will be caught by Microsoft.Owin.Diagnostics.ErrorPageExtensions.UserErrorPage

Tags:

owin

katana

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?

like image 248
Jun Guo Avatar asked Nov 25 '13 15:11

Jun Guo


1 Answers

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.

like image 114
Tratcher Avatar answered Oct 05 '22 07:10

Tratcher