Mark,
It should work fine as-is. You would need to import a few needed namespaces.
using System.Text; //Encoding
using System.IO; //Stream/Reader
using System.Net; //WebResponse/Request
If you don't want those namespaces imported, you could do this:
public static string GetUrlAsString(string url)
{
System.Net.WebRequest wReq = System.Net.WebRequest.Create(new Uri(url));
using (System.Net.WebResponse wResp = wReq.GetResponse())
using (System.IO.Stream respStream = wResp.GetResponseStream())
using (System.IO.StreamReader reader =
new System.IO.StreamReader(respStream, System.Text.Encoding.ASCII))
return reader.ReadToEnd().Trim();
} //end GetUrlAsString
"Mark" <mf****@idonotlikespam.cce.umn.edu> wrote in message
news:eZ*************@TK2MSFTNGP11.phx.gbl...
True, but doesn't the use of THREE using statements mess up the scope of
some of the variables? For example, wResp is out of scope by the time the
second Using statement executes - no? The code as-is didn't compile for
me.
Thanks.
Mark