0

我在 response.redirect() 处遇到异常,并且 Visual Studio 无法帮助我提供适当的信息。我只得到这个ex:expression cannot be evaluated,message: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
4

2 回答 2

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
于 2013-10-07T19:30:26.667 回答
1

这是预期的行为,作为一种解决方法,只需false传入Response.Redirect例如

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

或者正如已经建议的那样,摆脱Try...Catch- 不太确定你希望用 aThreadAbortException做什么......

于 2013-10-07T19:31:37.873 回答