title: How do I read text directly from a URL using VB.net?
body: <p>I'm making a Windows Phone 8 app. I have the latitude and longitude of the target location. I need to get the Two Letter ISO country code of target location.</p>
  
  <p>I'm using the following code to make it happen.</p>
  
  <pre><code>        'Dim address As String = puri
          'Dim client As WebClient = New WebClient()
          'Dim reader As StreamReader = New StreamReader(address)
          'code = reader.ReadToEnd
          Dim inStream As StreamReader
          Dim wr As WebRequest
          Dim webresponse As WebResponse
          wr = WebRequest.Create(puri)
          webresponse = wr.GetResponse()
          inStream = New StreamReader(webresponse.GetResponseStream())
          code = inStream.ReadToEnd()
  </code></pre>
  
  <p>where puri(in the commented code) is the address of the webservice in string format.</p>
  
  <p>When trying the commented code, the error I'm getting is that string cannot be converted to system.uri format. (address)</p>
  
  <p>When trying the uncommented code, I get an error which says, getresponse is not a member of class system.net.webrequest()</p>
  
  <p>I guess with the updates to .NET the code changed, but I couldn't find anything current on the topic.</p>
  
  <pre><code>URI = http://api.geonames.org/countryCode?lat=17.60890&amp;lng=76.98966&amp;username=demo
  </code></pre>