ThreadAbortedException的异常信息

时间:2013-10-07 19:27:40

标签: asp.net vb.net exception exception-handling

我在response.redirect()时遇到异常,而Visual Studio没有帮助我提供适当的信息。我只针对ex:expression cannot be evaluatedmessage:subprocess annulled_HResult:-2146233040获取此信息。我没有得到帮助链接或其他任何内容。

  Try

        Dim unidadD As String = Request.QueryString("unity")
        Dim categD As String = Request.QueryString("category")
        Dim resulD As String = Request.QueryString("result")
        Dim anioD As String = Request.QueryString("year")
        Dim cicloD As String = Request.QueryString("cicle")

        Response.Redirect("~/Evaluacion/Detalle_Resultados.aspx?op=1" & "&unity=" & unidadD & "&category=" & categD & "&result=" & resulD & "&cicle=" & cicloD & "&year=" & anioD)


       Catch exa As System.Threading.ThreadAbortException
           Dim link As String = exa.HelpLink
        End Try

2 个答案:

答案 0 :(得分:1)

Response.Redirect预计会抛出ThreadAbortedException。只需将Response.Redirect移出try / catch块即可。

另一种选择是使用:

Response.Redirect(url, False)

这将重定向而不会结束当前请求。您稍后可以拨打Application.CompleteRequest

另一种选择是

Try
    Response.Redirect(url)
Catch tax as ThreadAbortedException
    ' Do nothing, as this is an expected exception
    ' No need to rethrow, as this exception is automatically re-thrown
End Try

答案 1 :(得分:1)

这是expected行为,因为解决方法只是在false中传递Response.Redirect,例如

Response.Redirect("...", false);

或者如已经建议的那样,摆脱Try...Catch - 不太确定您对ThreadAbortException的期望是什么......