HTTP request in CF?

  • Thread starter Thread starter Jono
  • Start date Start date
J

Jono

I was able to issue HTTP request to download a remote
file from a web server using the webclient class in .net
framework.

However, the webclient class was not available in the
compact framework.

Is there a way to carry out the above mentioned task in
the compact framework?
 
Something like that:
private string GetHTML(string URL)
{
HttpWebRequest req = null;
HttpWebResponse resp = null;

req = (HttpWebRequest)WebRequest.Create(URL);
req.AllowWriteStreamBuffering = true;

req.AllowAutoRedirect = true;

resp = (HttpWebResponse)req.GetResponse();

StreamReader strResponse = new StreamReader(resp.GetResponseStream(),
Encoding.ASCII);
StringBuilder htmlData = new StringBuilder();
string line;

while ((line = strResponse.ReadLine()) != null)
{

htmlData.Append(line);
}
strResponse.Close();
resp.Close();
return htmlData.ToString();
}
 
Back
Top