By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,647 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,647 IT Pros & Developers. It's quick & easy.

HttpWebRequest Timout Error Problem

P: n/a
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();
}
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Matt" <sa*******@yahoo.com> 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.
Jul 22 '05 #2

P: n/a

Could someone please point me in the right direction.


Have a look at the following groups:
microsoft.public.dotnet.framework
microsoft.public.dotnet.framework.webservices

For a full listing of the MS groups conserning the
dotnet framework, have a look here:
http://groups.google.com/groups?hl=e...tnet.framework
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.