here is my threaded code that i use. see if you are missing anything.
strNumber =
System.Text.RegularExpressions.Regex.Replace(strNumber,"\\D",string.Empty);
// Create a new 'Uri' object with the specified string.
Uri myUri =new
Uri("
http://adp.infousa.com/fs?BAS_fsses...=2&BAS_flag2=1&SCH_origdb=FADP&sch_fullphone="
+ strNumber);
// Creates an System.Net.HttpWebRequest with the specified URL.
System.Net.HttpWebRequest myHttpWebRequest =
(System.Net.HttpWebRequest)WebRequest.Create(myUri);
myHttpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; Q312461; .NET CLR 1.0.3705)";
HttpWebResponse res = (HttpWebResponse)myHttpWebRequest.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(),
System.Text.Encoding.UTF8);
string pageContent = sr.ReadToEnd();
res.Close();
sr.Close();
--
Regards,
Alvin Bruney [Microsoft MVP ASP.NET]
[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @
http://www.lulu.com/owc
----------------------------------------------------------
Jan said:
I don't think I'm setting the useragent at all.
Jan
Alvin Bruney said:
It shouldn't. Are you setting the useragent correctly? How do you know it
is
hanging? Are there any exceptions?
--
Regards,
Alvin Bruney [Microsoft MVP ASP.NET]
[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @
http://www.lulu.com/owc
----------------------------------------------------------
I've got a program accessing a HTTP service to get som XML data.
The code receiveing the data looks something like this:
stream = new
StreamWriter(httpRequest.GetRequestStream(),Encoding.UTF8);
stream.Write(body);
stream.Close();
The httpRequest is a HttpWebRequest object.
This works fine from a single thread execution, but when I'm accessing
this
method on its own thread, the Close() method seems to hang.
Any ideas as to what I'm doing wrong?
Jan