English 中文(简体)
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 the 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.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签