我已经在本地IIS中配置了我的asp .net网站,如果我在app_Code文件中进行了任何更改,那么网站就会被编译,并且某些时候"线程正在被中止"错误被引发.我找不到原因或重现问题..给一些建议..
在我遇到过这种情况的情况下,它通常与在给定方法中的所有代码都有机会运行之前调用Response.Redirect,Server.Transfer或Response.End有关.举个例子:
try
{
//Call database method
}
catch(Exception ex)
{
Response.Redirect("error.aspx");
}
finally
{
Response.Redirect("success.aspx");
}
textbox1.Text = "complete!"; //Never called - Thread is being aborted exception
Run Code Online (Sandbox Code Playgroud)
在数据库调用抛出错误的情况下,重定向到error.aspx,否则会引发重定向到success.aspx,这意味着永远不会执行对textbox1.Text的调用,从而导致错误.
这是相关的知识库文章
- 编辑
如果您不确定抛出此问题的位置,我建议您处理Globabl.asax中的Application_Error事件并记录信息.此外,您可以查看服务器上的EventViewer,并查看是否在那里记录了异常.如果它是至少应该有堆栈跟踪.处理Application_Error事件的示例:
void Application_Error(object sender, EventArgs e)
{
var context = ((HttpApplication)sender).Context;
var ex = context.Server.GetLastError();
//Log exception
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13923 次 |
| 最近记录: |