每隔一段时间,Paypal就会向我的.net应用程序ipn脚本返回500错误代码。它将在验证请求的响应中返回该代码
以下是记录的错误:
System.Net.WebException 远程服务器返回错误:(500)内部服务器错误。
System.Web.HttpUnhandledException(0x80004005):抛出了类型为“System.Web.HttpUnhandledException”的异常。 ---> System.Net.WebException:远程服务器返回错误:(500)内部服务器错误。 在System.Net.HttpWebRequest.GetResponse() 在ASP.ipn_aspx.Page_Load(Object sender,EventArgs e)
我用于通话的代码是:
endPoint = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(endPoint);
//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
//Send the request to PayPal and get the response
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();
这可能每天发生一次,而PayPal不会重试ipn消息。其他95%的PayPal ipn交易正常运作。有什么想法吗?