asp.net - 查找 Visual Studio 2010 输出窗口中引发的首次机会异常的来源

标签 asp.net visual-studio-2010 debugging

我正在使用 Visual Studio 2010 开发 ASP.NET Web 应用程序。在调试过程中,有大量关于以下内容的输出窗口消息:

A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll

An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code

我读过一些关于 how 主题的精彩问答。和 why这些可能会被提出并且how to handle them (or not handle them)。我的第一个猜测是它与代码中的 Response.Redirect() 有关。但是,我在输出中看到它们,并且不确定这些输出消息的来源。

问题:如何确定 Visual Studio 2010 中第一个偶然异常来自何处?

一旦确定来源,我就可以根据与此问题相关的问答进行调查、解决或简单地忽略。提前致谢!

最佳答案

根据个人经验,除非因此而发生具体错误,否则这些消息通常可以忽略。

我过去读过,可以通过在 Response.Redirect 的第二个参数中添加 false 以停止重定向后发生的处理来解决此问题。

例如Response.Redirect("path/to/page.aspx", false);

Response.Redirect on MSDN

When you use this method in a page handler to terminate a request for one page and start a new request for another page, set endResponse to false and then call the CompleteRequest() method. If you specify true for the endResponse parameter, this method calls the End method for the original request, which throws a ThreadAbortException exception when it completes. This exception has a detrimental effect on Web application performance, which is why passing false for the endResponse parameter is recommended. For more information, see the End method.

关于asp.net - 查找 Visual Studio 2010 输出窗口中引发的首次机会异常的来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6528727/

相关文章:

c# - 方法参数的动态长度

c++ - strrchr 导致 'Cannot convert from const char * to char *'

c# - 在 C# Tcp 服务器中调试可能孤立的套接字

debugging - vsjitdebugger.exe 建议一个新实例,忽略已经运行的实例 - 怎么办?

asp.net - 使用 Javascript 更新客户端上的 TextBox 并从服务器读取值

javascript - Ajax AutoCompleteExtender 与 javascript

c# - ItemTemplate 中的控件无法在代码隐藏中调用

c# - 从VS2010 IDE启动时,为什么C#Release 3x会变慢?

visual-studio-2010 - 我们是否应该在使用 Visual Studio 和版本控制时忽略 Solution Output 文件夹?

arrays - Fortran 和 Visual Studio 调试中的自动数组长度