gpt4 book ai didi

owin - Microsoft.Owin.Diagnostics.ErrorPageExtensions.UserErrorPage 会捕获什么样的异常

转载 作者:行者123 更新时间:2023-12-04 11:38:57 27 4
gpt4 key购买 nike

我从 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会捕捉到哪些异常?我需要额外的配置才能让它工作吗?

最佳答案

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

关于owin - Microsoft.Owin.Diagnostics.ErrorPageExtensions.UserErrorPage 会捕获什么样的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20197429/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com