Hello all, I'm trying to create a simple application that does a HTTP request/response on a button click. Here's the entire code which I got from a reference book:
using
System.Collections.Generic;using System.ComponentModel;
using
System.Data;using
System.Drawing;using
System.Text;using
System.Windows.Forms;using
System.IO;using
System.Net;namespace
emulator2{
public partial class Form1 : Form{
public Form1(){
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e){
Uri l_Uri = new Uri("http://www.testing.com"); HttpWebRequest l_WebReq = (HttpWebRequest)WebRequest.Create(l_Uri); HttpWebResponse l_WebResponse = (HttpWebResponse)l_WebReq.GetResponse(); Stream l_responseStream = l_WebResponse.GetResponseStream(); StreamReader l_SReader = new StreamReader(l_responseStream); string resultstring = l_SReader.ReadToEnd(); Console.WriteLine(resultstring);}
}
}
The thing that puzzles me is that when I shift the entire chunk of code to a Windows Application, it works fine. But when I use it on a Device Application, it just throws me an error. Here are the details of the error:
System.Net.WebException was unhandled
Message="Could not establish connection to network."
StackTrace:
at System.Net.HttpWebRequest.finishGetResponse()
at System.Net.HttpWebRequest.GetResponse()
at emulator2.Form1.button1_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Button.OnClick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at emulator2.Program.Main()
The error points at this line:
HttpWebResponse l_WebResponse = (HttpWebResponse)l_WebReq.GetResponse();
Does anyone have any idea on how to solve this I need to get this solved real quick..so any help given is greatly appreciated! Thanks!
Oh btw, I'm using VS 2005 to compile/run the codes..forgot to include this in.

Problem with HTTPWebRequest on Pocket PC 2003 SE Emulator
thegallery
Hello,
You may want to check this blog(http://blogs.msdn.com/akhune/archive/2005/11/16/493329.aspx) so that connectivity to internet from Pocket Explorer is working. Once you find the connectivity from Pocket Explorer working, then please try the above sample again.
Hope this helps.
-Thanks,
Mohit