0

ANSWER! This is the code I was looking for! It basically needed the stream position to be reset to 0 before it would display text...hee-hee-hee-hee-hee!

async Task Hit()
    {
        HttpClient client = new HttpClient();
        HttpResponseMessage response = Task.Run(() => client.GetAsync("http://shotting.cc/")).Result;
        HitPage = response;

        HttpContent a = HitPage.Content;
        byte[] storage = new byte[1024];
        char[] chrStorage = new char[1024];
        Stream x = await a.ReadAsStreamAsync();
        StreamReader SR = new StreamReader(x);
        //StreamWriter SW = new StreamWriter(x);

        x.Position = 0;
        TB.Text = SR.ReadToEnd() + "JOB DONE";
        SR.Dispose();
       // SW.Dispose();
        return;
    }
  • 1
    You are ignoring exceptions, is it throwing one? BTW you should avoid `async void` and [you should not dispose HttpClient](https://contrivedexample.com/2017/07/01/using-httpclient-as-it-was-intended-because-youre-not/) after each use. – Crowcoder Jul 22 '17 at 14:11
  • Instead of "HttpResponseMessage response = await client.GetAsync ("http://google.co.uk/");" - use this "HttpResponseMessage response = Task.Run(() => client.GetAsync("http://google.co.uk/")).Result;" – Dinny Jul 22 '17 at 14:25
  • Basically, Got New Code now - but same problem. How to put the response in the textbox? I think its not possible, – Belly Knots Jul 22 '17 at 14:49
  • Thanks everyone. I'm a lot closer to getting my web page into a text box now. Here's the latest code. – Belly Knots Jul 22 '17 at 15:35

0 Answers0