Connecting through a computer with proxies

  • Thread starter Thread starter Ernesto Silva
  • Start date Start date
E

Ernesto Silva

Hello,

I have a computer that connects to internet using a password
authenticated proxy. I connect my PocketPC through this pc (pocket in
cradle) and i want to know if there are special things to do in my
source code to prevent this? The problem is that i have my connection
(work connection) in Pocket configured with proxies, pocket internet
explorer ask me for login/password but in my aplication the connection
just fails?
Please i need some help, thanks

Ernesto

PS: my actual source code
----------------------------------------------

public static DataSet SubmitAndGetXMLThread(string url, string xmlFile)
{
int theNrAtStopThread=MCommerceUtils.stopThread;

DataSet myDS=new DataSet();
xmlFile="XmlDocument="+xmlFile;
if(theNrAtStopThread==MCommerceUtils.stopThread)
{
try
{
HttpWebRequest req=(HttpWebRequest) WebRequest.Create(url);
req.Method="POST";
req.Timeout=35000;
System.Net.WebProxy myProxy = new WebProxy("192.168.0.17",4480);
req.Proxy = myProxy;

req.ContentType = "application/x-www-form-urlencoded";
req.AllowWriteStreamBuffering=true;

Stream newStream = req.GetRequestStream();



StreamWriter strw=new StreamWriter(newStream);

strw.Write(xmlFile);
strw.Flush();
strw.Close();
newStream.Flush();
newStream.Close();
if(theNrAtStopThread==MCommerceUtils.stopThread)
{
HttpWebResponse result = (HttpWebResponse) req.GetResponse();
Stream receiveStream;
try
{
//result.Close();
receiveStream = result.GetResponseStream();
}
catch(SocketException)
{

System.Windows.Forms.MessageBox.Show(MCommMessages.WebExceptionMessage,MCommMessages.__ApplicationName);
myDS.Clear();
myDS = null;
return myDS;
}
catch(System.Exception)
{

System.Windows.Forms.MessageBox.Show(MCommMessages.WebExceptionMessage,MCommMessages.__ApplicationName);
myDS.Clear();
myDS = null;
return myDS;
}
Encoding encode = Encoding.Default;

//System.Text.Encoding.GetEncoding("unicode");
//Encoding encode = System.Text.Encoding.GetEncoding("");
StreamReader sr = new StreamReader( receiveStream, encode );

Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 );
string output="";
while (count > 0)
{
output+=new String(read, 0, count);
count = sr.Read(read, 0, 256);
}

receiveStream.Flush();
receiveStream.Close();
sr.Close();
result.Close();
 
Ernesto,

You will need to construct a NetworkCredential object set the
HttpWebRequest.Credentials property. If you wish for the user to be
prompted for credentials, you will need to create and display an
appropriate form.

Thanks,
David Kline
Microsoft .NET Compact Framework
--------------------------------
This posting is provided “AS IS” with no warranties, and confers no
rights.

Please do not send email directly to this alias. This alias is for
newsgroup purposes only. To correspond with me directly, remove the
'online' from
my alias.
 
Back
Top