เป็นโค้ดเก่าจาก vs 2008 ที่เคยใช้งาน และนำมาเขียนใหม่บน vs 2015 ก็ขึ้น An unhandled exception of type 'System.Net.WebException' occurred in System.dll งงมากเลยครับ
Code (VB.NET)
Dim Username = txt_value.Text
Dim PostData = "account=" & Username
Dim request As WebRequest = WebRequest.Create("http://127.0.0.1/post.php")
request.Method = "POST"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(PostData)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
MsgBox(responseFromServer)