如何在Visual Basic 2013中使用DirectCast中的字符串



我正在尝试DirectCast Json,使用以下代码-

Dim EmailId as String
Dim URL as String
EmailId = txtEmailId.Text
URL = "http://localhost/json.php?id=" & EmailId
request = DirectCast(URL, HttpWebRequest)
response = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())

问题是,上面提到的方法只有在我硬编码电子邮件id到URL时才有效。例DirectCast("http://localhost/json.php?id=abcd@gmail.com", HttpWebRequest);当尝试获得电子邮件id作为变量时,我得到以下错误-

类型'String'的值不能转换为"System.Net.HttpWebRequest"。

请帮助我完成这项工作。

request = WebRequest.Create(URL)

最新更新