开发者

Does HttpWebRequest send 200 OK automatically?

Background: I am implementing Paypal IPN handler.

This great article on Paypal states that I am required to send a 200 OK back to Paypal after I read 开发者_如何学JAVAthe response.

The processing of IPN request is as follows:

//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(); //returns VERIFIED
streamIn.Close();

According to the following (from the article), the code (I guess) is supposed to send a 200 OK back to Paypal:

PayPal will respond with either VERIFIED or INVALID. After you receive this response, be sure to send 200 OK to prevent additional attempts from PayPal to send an IPN

I do not see any explicit HTTP response being sent as "200 OK".

Does the used HttpWebRequest send a 200 OK automatically?

If yes, at which point does that occur?

If not, how can one send 200 OK response using HttpWebRequest? Is it easier doing that using HttpWebRequest or sockets?


The short answer to the question you're really asking is yes, ASP.NET will send back a 200 if your page executes successfully. The point in the article that you are referring to is about you sending a request to Paypal in response to it's request to you, so sending 200 has nothing to do with the HttpWebRequest object as someone has already pointed out.

So, in the case of this article, if you want to send back 200 to Paypal, ASP.NET will do so automatically once the page has been successfully executed.


The easiest way to get the answer is to use Wireshark and see what exactly is getting sent back and forth.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜