post data through httpWebRequest

前端 未结 5 1281
情话喂你
情话喂你 2020-12-08 22:42

I need to \"Post\" some data to an external website using HttpWebRequest object from my application(desktop) and get a response back into my application through

5条回答
  •  臣服心动
    2020-12-08 23:18

    var request = WebRequest.Create("http://foo");
    request.Method = "POST";
    request.ContentType = "application/x-www-form-urlencoded";
    using (var writer = new StreamWriter(request.GetRequestStream()))
    {
        writer.Write("field=value");
    }
    

提交回复
热议问题