Easiest way to read the response from WebResponse

I would simply use the async methods on WebClient – much easier to work with:

        WebClient client = new WebClient();
        client.DownloadStringCompleted += (sender,args) => {
            if(!args.Cancelled && args.Error == null) {
                string result = args.Result; // do something fun...
            }
        };
        client.DownloadStringAsync(new Uri("http://foo.com/bar"));

But to answer the question; assuming it is text, something like (noting you may need to specify the encoding):

        using (var reader = new StreamReader(response.GetResponseStream()))
        {
            string result = reader.ReadToEnd(); // do something fun...
        }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)