HTTP request in CF?

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?
 
A

Alex Yakhnin, eMVP

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();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top