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

having trouble sending a post in using C#

P: n/a
here is my code that i am using to send the post to
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Text;
using System.Web;

public class MyCodeBehind : Page{
public TextBox login, partner, type, amount, user1;
public Button send;

public void send_Click(object sender, EventArgs e){
string login_s = login.Text;
string partner_s = partner.Text;
string type_s = type.Text;
string amount_s = amount.Text;
string user1_s = user1.Text;

ASCIIEncoding encoding=new ASCIIEncoding();
string postData="Login="+login_s;
postData += ("&partner="+partner_s);
postData += ("&type="+type_s);
postData += ("&amount="+amount_s);
postData += ("&user1="+user1_s);
byte[] data = encoding.GetBytes(postData);

// Prepare web request...
HttpWebRequest myRequest = (HttpWebRequest)
myRequest.Method = "POST";
myRequest.ContentLength = data.Length;
Stream newStream=myRequest.GetRequestStream();
// Send the data.
and i am getting the follwing error message:
Server Error in '/' Application.

The operation has timed-out.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace for more information about the error and where
it originated in the code.

Exception Details: System.Net.WebException: The operation
has timed-out.

Source Error:(line 45 is in red color, meaning the error
is in that line)
Line 43: myRequest.ContentType="application/x-www-
Line 44: myRequest.ContentLength = data.Length;
Line 45: Stream newStream=myRequest.GetRequestStream
Line 46: // Send the data.
Line 47: newStream.Write(data,0,data.Length);
Source File:
D:\root\fitfreak\\www\launch.cs Line:

Stack Trace:
[WebException: The operation has timed-out.]
System.Net.HttpWebRequest.GetRequestStream() +190
MyCodeBehind.send_Click(Object sender, EventArgs e) in
System.Web.UI.WebControls.Button.OnClick(EventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEve
ntHandler.RaisePostBackEvent(String eventArgument) +57
(IPostBackEventHandler sourceControl, String
eventArgument) +18
(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277

Can some please help, I will appriciate it highly

Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.