我正在尝试运行以下内容:
Dim a As Boolean = False
Try
Dim myHTTPWebRequest As HttpWebRequest = CType(WebRequest.Create(txtToShorten.Text), HttpWebRequest)
Dim myHTTPwebResponse As HttpWebResponse = CType(myHTTPWebRequest.GetResponse(), HttpWebResponse)
If myHTTPwebResponse.StatusCode = HttpStatusCode.OK Then
a = True
End If
Catch e As WebException
Catch e As Exception
End Try
Return a
当我执行正确的 url 时,它可以正常工作并返回 true,但是如果输入的 url 无效,则它不会返回值。
请问有什么想法吗?