PostAsync
のアプリケーションでHttpFormUrlEncodedContent
オブジェクトを使用しています。HttpFormUrlEncodedContentはsystem.Net.Httpの一部ではありません
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Threading.Tasks;
using System.Security.Cryptography;
using Newtonsoft.Json;
using System.Net;
using System.Net.Http;
次は私のポストを行うためのコードです:
タイプ:
var client = new HttpClient(); var values = new List<KeyValuePair<string, string>>(); values.Add(new KeyValuePair<string, string>("task", task)); values.Add(new KeyValuePair<string, string>("merchant", "2234-6566")); values.Add(new KeyValuePair<string, string>("ref", refl)); values.Add(new KeyValuePair<string, string>("hash", hash)); values.Add(new KeyValuePair<string, string>("amount", "20")); values.Add(new KeyValuePair<string, string>("seller", "[email protected]")); values.Add(new KeyValuePair<string, string>("remarks", "payment")); HttpFormUrlEncodedContent formContent = new HttpFormUrlEncodedContent(values); var content = new FormUrlEncodedContent(values); Task<HttpResponseMessage> t = client.PostAsync("https://epay.com/api/", content); t.Wait(); var response = t.Result;
はこれで私は以下のようにエラーメッセージが表示されますよう は、私はすべての必要な基準を置きますまたは名前空間名 'HttpFormUrlEncodedContent'を にできませんでした(使用するディレクティブまたはアセンブリ参照がありませんか)
この問題を解決するにはどうすればよいですか?
に値のコレクションを追加UWPアプリケーションのための 'Windows .Web .Http'からのものです。 – Nkosi