Annoying Bot
Annoying Bot

Reputation: 359

Fetching string from webpage into C# Form application

I want to set up a webpage with one small simple string on it. No images, no CSS, not anything else. Just a plain string that is not very long (maximum 20 char).

What is the best way to fetch this string with a C# Form application to use it for a variety of different purposes in the program, like showing people what the newest version of the software is when they boot it up.

Upvotes: 0

Views: 157

Answers (2)

betelgeuce
betelgeuce

Reputation: 837

I'd use System.Net.WebClient myself like this:

using (var client = new WebClient())
{
    string result = client.DownloadString("http://www.test.com");
    // TODO: do something with the downloaded result from the remote
}

Upvotes: 1

John Källén
John Källén

Reputation: 7943

Try using System.Net.WebClient:

        string remoteUri = "http://www.myserver.com/mypage.aspx";
        WebClient myWebClient = new WebClient();
        string version = myWebClient.DownloadString(remoteUri);

Upvotes: 0

Related Questions