Questions tagged «windows-phone-8.1»

5
如何使用HTTPclient内容类型进行POST = application / x-www-form-urlencoded
我目前正在开发wp8.1应用程序C#,通过从textbox.texts创建json对象(bm),我设法在json中对我的api执行POST方法。这是我的下面的代码。我该如何使用相同的textbox.text并将其发布为内容类型= application / x-www-form-urlencoded。这是什么代码? Profile bm = new Profile(); bm.first_name = Names.Text; bm.surname = surname.Text; string json = JsonConvert.SerializeObject(bm); MessageDialog messageDialog = new MessageDialog(json);//Text should not be empty await messageDialog.ShowAsync(); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json"); byte[] messageBytes = Encoding.UTF8.GetBytes(json); var content = new ByteArrayContent(messageBytes); content.Headers.ContentType …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.