我正在尝试将 json 发送到 php 页面,但结果始终为空。
try
{
using (WebClient webclient = new WebClient())
{
webclient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
webclient.Headers.Add("Content-Type", "application/json");
webclient.Encoding = System.Text.Encoding.UTF8;
string result = await webclient.UploadStringTaskAsync(url,"POST",json);
if (debug)
Console.WriteLine(" => " + result); // array(0) { }
}
}
json字符串是用
string json = Newtonsoft.Json.JsonConvert.SerializeObject(searchModel);
json输出是
{"term":"test","local":null,"localLabel":null,"result":null,"resultLabel":null,"genre":null,"costumer":null}
我的网址目标:
<?php echo var_dump($_POST); ?>
//doing $test="test" and adding $test inside var_dump shows the right value..
我在这里缺少什么?