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

StackOverflow https://stackoverflow.com/questions/20197429

  •  04-08-2022
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top