问题描述
过去的几个小时,我一直试图弄清楚为什么Paypal Sandbox IPN模拟器无法在我的请求中检测到Content-type.我没有修改发出请求的任何代码,所以奇怪的是它没有正确处理.
I've been using the past few hours attempting to figure out why the Paypal Sandbox IPN Simulator isn't detecting a Content-type on my request back. I didn't modify any of the code where the request back is made, so it's odd that it's not going through correctly.
曾经有一个类似的问题三月,尽管他标记的答案似乎对我没有帮助.
There was a similar question back in March, though the answer he marked didn't seem to do the trick for me.
有人对为什么会这样有任何想法吗?最近这件事发生在其他任何人身上吗?
Does anyone have any idea on why this is happening? Has this happened to anyone else recently?
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();
...
推荐答案
因此,使用ASHX无效,但是显然当我切换到ASPX文件时,它神奇地起作用了.我不确定ASHX有什么功能无法解决问题,但是ASPX是解决方案.
So, using ASHX didn't work, but apparently when I switched over to a ASPX file, it magically worked. I'm not sure what ASHX has that doesn't make it work, but ASPX was the solution.
这篇关于贝宝沙盒IPN未检测到内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!