0
我有購買後處理PayPal IPN的以下C#ASP.Net代碼。我已將PayPal設置中的編碼設置爲UTF8。當我用ASCII編碼將代碼發回PayPal(代碼中的所有UTF8替換爲ASCII)時,一切正常。當我用UTF8編碼發送請求時,我收到「請求被中止:請求被取消。」在最後一行的streamOut.Close()處出現異常。我正在使用啓用了IIS 7和.Net 2的Godaddy Shared Hosting。有什麼建議麼?」請求被中止:請求被取消。「同時處理PayPal IPN
protected void Page_Load(object sender, EventArgs e)
{
string strRequest = string.Empty;
try
{
string strLive = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strLive);
req.KeepAlive = false;
req.ReadWriteTimeout = 600000;
req.Timeout = 600000;
//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
strRequest = Encoding.UTF8.GetString(param);
strRequest += "&cmd=_notify-validate";
req.ContentLength = System.Text.Encoding.UTF8.GetByteCount(strRequest);
//Send the request to PayPal and get the response
Stream RequestStream = req.GetRequestStream();
StreamWriter streamOut = new StreamWriter(RequestStream, System.Text.Encoding.UTF8);
RequestStream.ReadTimeout = 600000;
RequestStream.WriteTimeout = 600000;
streamOut.Write(strRequest);
streamOut.Close(); // EXCEPTION: "The request was aborted: The request was canceled."