[英]PayPal IPN Sandbox error with asp.net
I have a problem with IPN Sandbox and ASP.NET 4.0. 我对IPN沙箱和ASP.NET 4.0有问题。 The same code that I use for the production part does not work with SandBox.
我在生产部件中使用的相同代码不适用于SandBox。
The error that is raised is as follows: 引发的错误如下:
Exception message: The underlying connection was closed: An unexpected error occurred on a send. 异常消息:基础连接已关闭:发送时发生意外错误。
This is the code: 这是代码:
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
string strResponse_copy = strRequest; //Save a copy of the initial info sent by PayPal
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
The error was raised on the line 错误在网上提出
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
The code that deals instead of calling the payment page works fine. 处理而不是调用付款页面的代码可以正常工作。
How can I fix ? 我该如何解决?
If the same code works on the production site, but not the Sandbox, it is very likely an intermittent network issue with the Sandbox environment. 如果相同的代码在生产站点上有效,但不能在沙盒上运行,则很可能是沙盒环境出现间歇性网络问题。
I have seen this and related issues with the Sandbox recently. 最近,我已经看到了此问题以及与沙盒相关的问题。 Keep retrying the code, I believe certain requests will go through, and others get dropped.
继续重试代码,我相信某些请求会通过,而其他请求会被丢弃。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.