View Single Post
  #29 (permalink)  
Old September 20th, 2007, 07:03 AM
olupenko olupenko is offline
Registered User
Join Date: Sep 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Hi How can I do this in .Net 1.1 for example .Net 1.1 does not accept this line of code

Any ideas?

quote:Originally posted by xins
 "The underlying connection was closed: An unexpected error occurred on a receive."

i have the same problem as you. please see this page first for the main problem in .NET :

well i added thos recommended code but it still has the same error in my program so i add some code and it's works, try this :

private string requestpost(String TheURL,string postdata, String TheProxy)
  Uri uri = new Uri(TheURL);
  HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
  string page;
    string postsourcedata=postdata;

    // start added codes
    request.KeepAlive = false;
    request.Method = "POST";
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = postsourcedata.Length;
    request.Proxy = System.Net.WebProxy.GetDefaultProxy();
    request.Timeout=(int) new TimeSpan(0,0,60).TotalMilliseconds;
    request.UserAgent="Mozilla/3.0 (compatible; My Browser/1.0)";
    // end added codes

    Stream writeStream = request.GetRequestStream();
    byte[] bytes = System.Text.Encoding.ASCII.GetBytes(postsourcedata );
    writeStream.Write(bytes, 0, bytes.Length);

    HttpWebResponse response = (HttpWebResponse) request.GetResponse();
    Stream responseStream = response.GetResponseStream();
    StreamReader readStream = new StreamReader (responseStream, Encoding.UTF8);

    page = readStream.ReadToEnd();
  catch (Exception ee)
    page = "fail!";
  return page;

hopefully your troubled solved..



(by the way have u watch LORD OF THE RING : RETURN OF THE KING?)

See u in matrix
Reply With Quote