我在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
答案 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
的期望是什么......