having trouble sending a post in asp.net using C#

K

khawar

here is my code that i am using to send the post to
verisign:
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)
WebRequest.Create
("https://payflowlink.verisign.com/payflowlink.cfm");
myRequest.Method = "POST";
myRequest.ContentType="application/x-www-form-
urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream=myRequest.GetRequestStream();
// Send the data.
newStream.Write(data,0,data.Length);
newStream.Close();
}
}
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-
form-urlencoded";
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\trainwithdom.com\www\launch.cs Line:
45

Stack Trace:


[WebException: The operation has timed-out.]
System.Net.HttpWebRequest.GetRequestStream() +190
MyCodeBehind.send_Click(Object sender, EventArgs e) in
D:\root\fitfreak\trainwithdom.com\www\launch.cs:45
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
+108

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top