How to Get the HTTP Post data in C#? How to Get the HTTP Post data in C#? asp.net asp.net

How to Get the HTTP Post data in C#?


This code will list out all the form variables that are being sent in a POST. This way you can see if you have the proper names of the post values.

string[] keys = Request.Form.AllKeys;for (int i= 0; i < keys.Length; i++) {   Response.Write(keys[i] + ": " + Request.Form[keys[i]] + "<br>");}


This code reads the raw input stream from the HTTP request. Use this if the data isn't available in Request.Form or other model bindings or if you need access to the bytes/text as it comes.

using(var reader = new StreamReader(Request.InputStream))    content = reader.ReadToEnd();


You can simply use Request["recipient"] to "read the HTTP values sent by a client during a Web request"

To access data from the QueryString, Form, Cookies, or ServerVariables collections, you can write Request["key"]

Source: MSDN

Update: Summarizing conversation

In order to view the values that MailGun is posting to your site you will need to read them from the web request that MailGun is making, record them somewhere and then display them on your page.

You should have one endpoint where MailGun will send the POST values to and another page that you use to view the recorded values.

It appears that right now you have one page. So when you view this page, and you read the Request values, you are reading the values from YOUR request, not MailGun.