如果我对 try/catch 块中的错误的响应是将用户重定向到错误页面,那么 try/catch 块的行为就好像没有错误一样。如果我将其更改为执行其他操作,则代码可以正常工作。
例子:
try
{
//do this SQL server stuff
}
catch
{
Response.Redirect(error.htm)
//Change this to lblErr.Text = "SQL ERROR"; and the code in try works fine.
}
从另一篇文章中,我了解到 Response.Redirect() 方法存在布尔重载。我尝试了 true 和 false 并且 try/catch 块仍然表现得好像有错误一样。
这是怎么回事?