gpt4 book ai didi

asp.net-mvc - Application_Error 被调用但没有异常

转载 作者:行者123 更新时间:2023-12-04 15:46:40 24 4
gpt4 key购买 nike

在 VS2010 SP1 中调试我的 MVC 4 应用程序时,Application_Error()处理程序被调用,但 Server.GetLastError()为空。

protected void Application_Error()
{
var exception = Server.GetLastError();
// exception is null. How is that possible?
}

MSDN states Application_Error

called if an unhandled exception occurs anywhere in your ... application... You can get information about the most recent error from the GetLastError method.



Server.GetLastError 的 MSDN 文档() 状态

Return value: The previous exception that was thrown.



我怎么可能处于 Application_Error() 的状态被调用但是 Server.GetLastError()返回空?

最佳答案

您是否在 web.config 中使用自定义错误处理?我相信如果浏览器发出重定向,之前的异常就会丢失。拿个 look at this answer看看你的情况是否相似。

关于asp.net-mvc - Application_Error 被调用但没有异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11682681/

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