C# 에서 POST 방식으로 웹페이지 호출

C#에서 호출

 

C# 에서 POST 방식으로 웹페이지 호출하는 방법입니다.

 

NameValueCollection POST = new NameValueCollection();
POST.Add("cmd", "mycommand");
WebClient web = new WebClient();

string URL = "http://whiteat.com/home/command.php";

return Encoding.UTF8.GetString(web.UploadValues(URL, "POST", POST));

 

웹페이지에서 처리

$cmd = $_POST['cmd'];
echo "command is ".$cmd;

// output
command is mycommand

 

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다