E
Erphan
Hi,
I am creating a simple WebRequest to access a web address. working great but
when i restart the device and lunch my application and initiate that web
request it halts or sumtimes it doesn't.
THIS HAPPENS WHEN THERE IS NO CONNECTION TO INTERNET IS AVAILABLE. ( No
Wifi, No GPRS/EDGE, No ActiveSync)
Language: C#
..NET Framework: 1.0 CF
Device: HTC S710
OS Ver: Windows Mobile 6 Standard
Code:
public static bool GetHTTPData(string strVal, out string strReturn)
{
strReturn = "";
Cursor.Current = Cursors.WaitCursor;
try
{
HttpWebRequest req =
(HttpWebRequest)HttpWebRequest.Create(strVal);
req.Method = "GET";
req.Timeout = 30000;
WebResponse resp = req.GetResponse();
StreamReader read = new
StreamReader(resp.GetResponseStream());
strReturn = read.ReadToEnd();
read.Close();
resp.Close();
req.Abort();
req = null;
}
catch (WebException we)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(Constants.Lang.ConnectionGenericException,
Constants.Lang.ConnectionFailed, MessageBoxButtons.OK,
MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
return false;
}
catch (Exception ex)
{
System.Windows.Forms.Cursor.Current = Cursors.Default;
MessageBox.Show(Constants.Lang.ConnectionGenericException,
Constants.Lang.ConnectionFailed, MessageBoxButtons.OK,
MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
return false;
}
finally
{
Cursor.Current = Cursors.Default;
}
return true;
}
I am creating a simple WebRequest to access a web address. working great but
when i restart the device and lunch my application and initiate that web
request it halts or sumtimes it doesn't.
THIS HAPPENS WHEN THERE IS NO CONNECTION TO INTERNET IS AVAILABLE. ( No
Wifi, No GPRS/EDGE, No ActiveSync)
Language: C#
..NET Framework: 1.0 CF
Device: HTC S710
OS Ver: Windows Mobile 6 Standard
Code:
public static bool GetHTTPData(string strVal, out string strReturn)
{
strReturn = "";
Cursor.Current = Cursors.WaitCursor;
try
{
HttpWebRequest req =
(HttpWebRequest)HttpWebRequest.Create(strVal);
req.Method = "GET";
req.Timeout = 30000;
WebResponse resp = req.GetResponse();
StreamReader read = new
StreamReader(resp.GetResponseStream());
strReturn = read.ReadToEnd();
read.Close();
resp.Close();
req.Abort();
req = null;
}
catch (WebException we)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(Constants.Lang.ConnectionGenericException,
Constants.Lang.ConnectionFailed, MessageBoxButtons.OK,
MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
return false;
}
catch (Exception ex)
{
System.Windows.Forms.Cursor.Current = Cursors.Default;
MessageBox.Show(Constants.Lang.ConnectionGenericException,
Constants.Lang.ConnectionFailed, MessageBoxButtons.OK,
MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
return false;
}
finally
{
Cursor.Current = Cursors.Default;
}
return true;
}