By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,207 Members | 1,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,207 IT Pros & Developers. It's quick & easy.

problem with HTTPWebRequest on Pocket PC 2003 SE Emulator

P: n/a
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!

May 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
on web it works on HTTP POST but Device application works on soap.

"bl*****@yahoo.com" wrote:
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!

May 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.