2013-11-25 6 views
7

http://blogs.msdn.com/b/webdev/archive/2013/11/22/debugging-owin-app-or-framework.aspx에서 데모 코드를 얻었습니다. 그리고 그것은 섹시한 오류 페이지를 보여줍니다.어떤 종류의 예외가 Microsoft.Owin.Diagnostics.ErrorPageExtensions.UserErrorPage에 의해 잡힐 것입니까

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

그러나 컨트롤러 작업에서 예외가 발생하면 오류 페이지가 표시되지 않고 여전히 YSOD가 표시됩니다.

그래서 UseErrorPage에서 어떤 예외가 잡히게되는지 알고 싶습니까? 작동하려면 추가 구성이 필요합니까?

+1

웹 API는 예외를 처리하고 UseErroPage 미들웨어가 처리하기 전에 500 응답으로 변환하는 것처럼 보입니다. 일반적으로 파이프 라인의 처리되지 않은 응답은 UseErrorPage 미들웨어에 의해 처리됩니다. – Praburaj

답변

7

그리고 컨트롤러 동작으로 MVC를 의미합니까? MVC는 OWIN에서 직접 실행되지 않으므로 Asp.Net은 먼저 예외를보고 YSOD를 표시합니다. Katana ErrorPage는 OWIN 파이프 라인에서 발생하는 예외 만 표시 할 수 있습니다.

+0

감사합니다. –