i got a nice problem here:
my page recieves a request, it then sends a request back to the other server with all of the same params as the orignal requess, and waits for a responce the responce should be "Valid" or "Invalid"
and then my pages sends back the orignal response witch is discarded.
When i run on local.host everything works perfectly.
I upload my files to the server, and run the page and it crashes at this line of code:
[code=cpp]
StreamWriter streamOut = new StreamWriter(re q.GetRequestStr eam(), System.Text.Enc oding.ASCII);
[/code]
the full function is:
[code=cpp]
protected void Page_Load(objec t sender, EventArgs e)
{
LogAMessage.log AMessage("1");
//Post back to either sandbox or live
string strSandbox = "https://www.sandbox.pay pal.com/cgi-bin/webscr";
//string strLive = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest )WebRequest.Cre ate(strSandbox) ;
LogAMessage.log AMessage("2");
//Set values for the request back
req.Method = "POST";
LogAMessage.log AMessage("3");
req.ContentType = "applicatio n/x-www-form-urlencoded";
LogAMessage.log AMessage("4");
byte[] param = Request.BinaryR ead(HttpContext .Current.Reques t.ContentLength );
LogAMessage.log AMessage("5");
string strRequest = Encoding.ASCII. GetString(param );
LogAMessage.log AMessage("6");
strRequest += "&cmd=_noti fy-validate";
LogAMessage.log AMessage("7");
req.ContentLeng th = strRequest.Leng th;
LogAMessage.log AMessage("8");
//for proxy
//WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
//req.Proxy = proxy;
//Send the request to PayPal and get the response
StreamWriter streamOut = new StreamWriter(re q.GetRequestStr eam(), System.Text.Enc oding.ASCII);
LogAMessage.log AMessage("9");
streamOut.Write (strRequest);
LogAMessage.log AMessage("10");
streamOut.Close ();
LogAMessage.log AMessage("11");
StreamReader streamIn = new StreamReader(re q.GetResponse() .GetResponseStr eam());
LogAMessage.log AMessage("12");
string strResponse = streamIn.ReadTo End();
LogAMessage.log AMessage("13");
streamIn.Close( );
LogAMessage.log AMessage("14");
if (strResponse == "VERIFIED")
{
LogAMessage.log AMessage("IPN is Verified");
}
else if (strResponse == "INVALID")
{
LogAMessage.log AMessage("IPN is INVALID");
}
else
{
LogAMessage.log AMessage("IPN BROKEN");
}
}
[/code]
the LogAMessage.log AMessage() function is a simple function that writes a message to a text file. My text file gets up to number 8 and then nothing.
Thanks for your help.
my page recieves a request, it then sends a request back to the other server with all of the same params as the orignal requess, and waits for a responce the responce should be "Valid" or "Invalid"
and then my pages sends back the orignal response witch is discarded.
When i run on local.host everything works perfectly.
I upload my files to the server, and run the page and it crashes at this line of code:
[code=cpp]
StreamWriter streamOut = new StreamWriter(re q.GetRequestStr eam(), System.Text.Enc oding.ASCII);
[/code]
the full function is:
[code=cpp]
protected void Page_Load(objec t sender, EventArgs e)
{
LogAMessage.log AMessage("1");
//Post back to either sandbox or live
string strSandbox = "https://www.sandbox.pay pal.com/cgi-bin/webscr";
//string strLive = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest )WebRequest.Cre ate(strSandbox) ;
LogAMessage.log AMessage("2");
//Set values for the request back
req.Method = "POST";
LogAMessage.log AMessage("3");
req.ContentType = "applicatio n/x-www-form-urlencoded";
LogAMessage.log AMessage("4");
byte[] param = Request.BinaryR ead(HttpContext .Current.Reques t.ContentLength );
LogAMessage.log AMessage("5");
string strRequest = Encoding.ASCII. GetString(param );
LogAMessage.log AMessage("6");
strRequest += "&cmd=_noti fy-validate";
LogAMessage.log AMessage("7");
req.ContentLeng th = strRequest.Leng th;
LogAMessage.log AMessage("8");
//for proxy
//WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
//req.Proxy = proxy;
//Send the request to PayPal and get the response
StreamWriter streamOut = new StreamWriter(re q.GetRequestStr eam(), System.Text.Enc oding.ASCII);
LogAMessage.log AMessage("9");
streamOut.Write (strRequest);
LogAMessage.log AMessage("10");
streamOut.Close ();
LogAMessage.log AMessage("11");
StreamReader streamIn = new StreamReader(re q.GetResponse() .GetResponseStr eam());
LogAMessage.log AMessage("12");
string strResponse = streamIn.ReadTo End();
LogAMessage.log AMessage("13");
streamIn.Close( );
LogAMessage.log AMessage("14");
if (strResponse == "VERIFIED")
{
LogAMessage.log AMessage("IPN is Verified");
}
else if (strResponse == "INVALID")
{
LogAMessage.log AMessage("IPN is INVALID");
}
else
{
LogAMessage.log AMessage("IPN BROKEN");
}
}
[/code]
the LogAMessage.log AMessage() function is a simple function that writes a message to a text file. My text file gets up to number 8 and then nothing.
Thanks for your help.
Comment