在过去的几个小时里,我一直在试图弄清楚为什么 Paypal Sandbox IPN 模拟器没有在我的请求中检测到内容类型。我没有修改任何返回请求的代码,所以奇怪的是它没有正确通过。
三月份有一个类似的问题,尽管他标记的答案似乎对我没有用。
有谁知道为什么会这样?最近有其他人发生过这种情况吗?
public class PaypalIPN : IHttpHandler, IRequiresSessionState {
public void ProcessRequest (HttpContext context)
{
//post back to either sandbox or live
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
string strLive = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = context.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();
...