System.Net.WebException: The operation has timed-out.??? Pls help

  • Thread starter Thread starter Shayer
  • Start date Start date
S

Shayer

Hi,

I m trying to retreive some information from a webpage using the
following code

for(i=0;i<imageList.Count;i++)
{
saveimage:
try
{
Console.WriteLine("Trying to save image:"+imageList.ToString());
j = imageList.ToString();
WebRequest req = WebRequest.Create(j);
WebResponse res =req.GetResponse();
Stream strm = res.GetResponseStream();
BinaryReader br = new BinaryReader(strm);
long len = res.ContentLength;
Image img = Image.FromStream(strm);
img.Save(GIFFolderPath+@"\"+NewFileName);
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
goto saveimage;
}//try catch
}//for


Actually when i try this code in Dial Up network it works fine but
when i tried it in the client-server network like when i am connected to
internet using another server .. after retreiving first two image it hangs
up and give the following error

=======================

System.Net.WebException: The operation has timed-out.
at System.Net.HttpWebRequest.GetResponse()
at prjJLCV.SaveToDataBase.SaveImageData(ArrayList imageList, String
GIFFolder
Path, String MaxPropertyID, String PropertyID) in c:\currentworks\jlc
values\mar
ch22\jlcv_final\prjjlcv\savetodatabase.cs:line
280=========================================

i am tring this code from a windows console application

Can anyone tell me where is the problem
 
Shayer,

Is it possible that the network that you are on is using a proxy that
needs to be configured? If you go to IE and check the proxy settings, is it
automatic, or are there entries? If a proxy is used, then you can set the
Proxy property on the WebRequest to the value returned from a call to the
static GetDefaultProxy method on the WebProxy class.

Hope this helps.
 
Hello Nicholas

Thanks for your response. It works fine up to one extent. Now the program
can retreive the text part from the HTML
But when i am trying to retreive an image from an specified url it is not
working and throws me the exception as before

Can u pls point me what should i do

THanks

Regards

Shayer

Nicholas Paldino said:
Shayer,

Is it possible that the network that you are on is using a proxy that
needs to be configured? If you go to IE and check the proxy settings, is it
automatic, or are there entries? If a proxy is used, then you can set the
Proxy property on the WebRequest to the value returned from a call to the
static GetDefaultProxy method on the WebProxy class.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Shayer said:
Hi,

I m trying to retreive some information from a webpage using the
following code

for(i=0;i<imageList.Count;i++)
{
saveimage:
try
{
Console.WriteLine("Trying to save image:"+imageList.ToString());
j = imageList.ToString();
WebRequest req = WebRequest.Create(j);
WebResponse res =req.GetResponse();
Stream strm = res.GetResponseStream();
BinaryReader br = new BinaryReader(strm);
long len = res.ContentLength;
Image img = Image.FromStream(strm);
img.Save(GIFFolderPath+@"\"+NewFileName);
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
goto saveimage;
}//try catch
}//for


Actually when i try this code in Dial Up network it works fine but
when i tried it in the client-server network like when i am connected to
internet using another server .. after retreiving first two image it hangs
up and give the following error

=======================

System.Net.WebException: The operation has timed-out.
at System.Net.HttpWebRequest.GetResponse()
at prjJLCV.SaveToDataBase.SaveImageData(ArrayList imageList, String
GIFFolder
Path, String MaxPropertyID, String PropertyID) in c:\currentworks\jlc
values\mar
ch22\jlcv_final\prjjlcv\savetodatabase.cs:line
280=========================================

i am tring this code from a windows console application

Can anyone tell me where is the problem


 
Back
Top