HttpWebRequest Timout Error Problem

Discussion in 'C++' started by Matt, Jan 28, 2004.

  1. Matt

    Matt Guest

    I am having trouble with the HttpWebRequest.GetRequestStream method.

    I am posting data to my web server running NT4 iis4 using a loop. So
    every time the loop executes I want it to post data to my web page.
    It work the first 2 times the loop iterates, but on the third time
    around it gives me a timout error.

    The line it gives me an error on is:
    --Stream newStream = myRequest.GetRequestStream();--

    Could someone please point me in the right direction.

    Many thanks!


    Form Code:
    private void button1_Click(object sender, System.EventArgs e)
    {
    int x;
    x=0;
    while(x < 1)
    {
    this.textBox1.Text = "Sleeping";
    Application.DoEvents();
    Thread.Sleep(3000);

    HRATS_Functions X = new HRATS_Functions();

    try
    {
    X.PostData();
    X.Dispose();
    //this.textBox2.Text = X.myResponse.ToString();
    }
    catch (Exception a)
    {
    this.textBox1.Text = "Exception: " + a.ToString();
    break;
    }

    this.textBox1.Text = "Awake";
    Application.DoEvents();
    Thread.Sleep(3000);
    }
    }


    Class Code:
    public HttpWebRequest myRequest =
    (HttpWebRequest)Request.Create("http://lab/collectdata.asp");
    public ASCIIEncoding encoding = new ASCIIEncoding();
    public string myResponse;

    public void PostData()
    {
    // Initialize the WebRequest parameters
    string postData = "First_Name=Matt";
    byte[] byte1 = encoding.GetBytes(postData);

    //Set Request Properties
    myRequest.Method = "POST";
    myRequest.ContentType = "application/x-www-form-urlencoded";
    myRequest.ContentLength = postData.Length;
    myRequest.Timeout = 5000;

    //send the request
    Stream newStream = myRequest.GetRequestStream();
    newStream.Write(byte1,0,byte1.Length);
    newStream.Flush();
    newStream.Close();
    }
    Matt, Jan 28, 2004
    #1
    1. Advertising

  2. "Matt" <> wrote...
    > I am having trouble with the HttpWebRequest.GetRequestStream method.
    >
    > I am posting data to my web server running NT4 iis4 using a loop. So
    > every time the loop executes I want it to post data to my web page.
    > It work the first 2 times the loop iterates, but on the third time
    > around it gives me a timout error.
    > [...]


    This has nothing to do with the language. Please post to a forum
    where 'HttpWebRequest' is on topic, I think you should find more help
    in comp.os.ms-windows.programmer.win32.
    Victor Bazarov, Jan 28, 2004
    #2
    1. Advertising

  3. Matt

    Fred H Guest

    Fred H, Jan 28, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWc=?=

    Session timout problem

    =?Utf-8?B?bWc=?=, Feb 22, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    1,237
    Alvin Bruney [MVP]
    Feb 23, 2004
  2. Ken Varn
    Replies:
    2
    Views:
    325
    Ken Varn
    May 28, 2004
  3. Eyal Sharabi Horwitz

    timout expired

    Eyal Sharabi Horwitz, Jul 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    339
    Eyal Sharabi Horwitz
    Jul 29, 2004
  4. Steve Peterson

    Session object timout

    Steve Peterson, Dec 26, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    653
    Steve Peterson
    Dec 27, 2004
  5. Dean g

    upload timout problem

    Dean g, May 10, 2005, in forum: ASP General
    Replies:
    2
    Views:
    104
    Kyle Peterson
    May 10, 2005
Loading...

Share This Page