Problems capturing HTTP response

I have this code which successfully makes an HTTP request:

                //Successful request
                var requestInBytes = encoding.GetBytes(urlWithParameters.ToString());

                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlWithParameters.ToString());
                req.Method = "POST";
                req.ContentLength = requestInBytes.Length;
                req.ContentType = "application/x-www-form-urlencoded";

                Stream newStream = req.GetRequestStream();

                // Send the data.
                newStream.Write(requestInBytes, 0, requestInBytes.Length);

However, I'm having trouble capturing the response. Right now, I'm trying this:

            //No response?
            System.IO.StreamReader st = new StreamReader(((HttpWebResponse)req.GetResponse()).GetResponseStream());
            var response = st.ReadLine();

But this is coming back with a blank response?



HTTPWebResponse response = req.GetResponse();

You can then check the various properties of the response.



var response= req.ReadToEnd();

Need Your Help

How to get NodeJS to evaluate multiple traditional JS files

javascript node.js

We are using nodejs as an js engine to evaluate some student scripts on the server side so we can test their correctness.

Faking abstract methods using exceptions in Java

java exception abstract-methods

I've been asked this question and am frankly stumped: