Retrieving data from a POST method in ASP.NET

前端 未结 3 1345
臣服心动
臣服心动 2020-12-15 03:39

I am using ASP.NET.

There is a system that needs to POST data to my site and all they asked for is for me to provide them with a URL. So I gave them my URL http://ww

3条回答
  •  萌比男神i
    2020-12-15 04:06

    The data from the request (content, inputs, files, querystring values) is all on this object HttpContext.Current.Request
    To read the posted content

    StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream);
    string requestFromPost = reader.ReadToEnd();
    

    To navigate through the all inputs

    foreach (string key in HttpContext.Current.Request.Form.AllKeys)
    {
       string value = HttpContext.Current.Request.Form[key];
    }
    

提交回复
热议问题