System.Net.WebException'发生在System.dll中

时间:2017-08-28 17:56:39

标签: asp.net vb.net exception

完整的例外情况如下:

An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code

Additional information: The remote server returned an error: (404) Not Found.

我的代码如下所示:

Public Function GetHash(password As String) As String Implements IHashManager.GetHash
        Dim uRL As String = HttpContext.Current.Request.Url.Scheme & "://" & HttpContext.Current.Request.Url.Host & ":" & HttpContext.Current.Request.Url.Port & "/md5_hash.asp?val=" & password

        ' Dim myWebClient As New Net.WebClient
        Using myWebClient As New Net.WebClient
            Return myWebClient.DownloadString(uRL)
        End Using
    End Function

它会在返回行上抛出异常。

代码的目的是使用当前URL返回密码的哈希值。我没有写这段代码,我不确定它为什么会出错。有谁知道为什么?

1 个答案:

答案 0 :(得分:0)

当您致电uRL时,您需要检查myWebClient.DownloadString()的价值。 "附加信息"非常清楚;您收到404错误,指出在uRL中找不到的资源在该位置找不到/不存在。