Getting web file content from url with asp.net
Here's how you could get page or file content with help of webclient class and use it for exaple to get the forex rates or regional weather forecast from diferent page and show it to yours:
First we need to import the requred name spaces:
Imports System.Net
Imports System.IO
Second there we go with our method:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadDim client As New WebClient
Dim sr As StreamReader = New StreamReader(client.OpenRead("http://www.snb-bg.com/test.txt"), System.Text.Encoding.Default(), False)Dim sb As New StringBuilder
Do While sr.Peek >= 0sb.Append(sr.ReadLine())
Loop
Label1.Text = sb.ToString()
client.Dispose()
sr.Dispose()
sr.Close()
End Sub
I think this example is quite easy and don't need more explanation, but in case you need please feel free to send me feedback.
Regards