2017-08-28 28 views
0

完整的例外是這樣的:System.Net.WebException」發生在System.dll中

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返回密碼的哈希值。我沒有寫這個代碼,我不確定它爲什麼會出錯。有誰知道爲什麼?

回答

0

當您撥打myWebClient.DownloadString()時,您需要檢查uRL的值。 「附加信息」非常清楚;你會得到一個404錯誤,說明uRL中標識的資源在該位置沒有找到/不存在。

+1

你也不應該使用你不明白的代碼。 –

+0

感謝您的回覆,此問題的目的是爲了更好地理解代碼並解決問題。我儘量不使用我不明白的代碼 – Andrew

相關問題