我寫UWP應用程序,我使用HttpClient()
與服務器通信UWP解析或反序列化的HttpClient響應
下面的代碼,我到目前爲止已經試過
public async void POSTreq()
{
Uri requestUri = new Uri("http://www.example.com");
string myParameters = "_action=LOGIN&[email protected]&password=123456789";
json = JsonConvert.SerializeObject(myParameters);
var objClint = new System.Net.Http.HttpClient();
System.Net.Http.HttpResponseMessage respon = await objClint.PostAsync(requestUri, new StringContent(myParameters, Encoding.UTF8, "application/x-www-form-urlencoded"));
var responJsonText = await respon.Content.ReadAsStringAsync();
Debug.WriteLine(responJsonText);
}
我不知道該怎麼迴應轉換數據字典或列表格式
{"redirecturl":"https:\/\/www.example.com","status":"success","timestamp":1487906895,"community":"","communitystr":null,"currentworkspace":"w","schemarevision":null,"persona":null,"username":"[email protected]","isadmin":"false","email1status":null}
上面的字符串應該轉換爲
output['redirecturl']="https:/\/\www.example.com"
output['status']="success" etc..
作爲註釋只需記住來處理網絡異常 – Corcus