C# HttpFormUrlEncodedContent不是system.Net.Http的一部分

C# HttpFormUrlEncodedContent不是system.Net.Http的一部分,c#,C#,我正在应用程序中使用HttpFormUrlEncodedContent对象进行PostAsync。 我将所有必要的参考放在如下位置: 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 Syst

我正在应用程序中使用
HttpFormUrlEncodedContent
对象进行
PostAsync
。 我将所有必要的参考放在如下位置:

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", "mymail@mail.com"));
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;
var-client=new-HttpClient();
var值=新列表();
添加(新的KeyValuePair(“任务”,任务));
添加(新的KeyValuePair(“商户”,“2234-6566”);
添加(新的KeyValuePair(“ref”,refl));
添加(新的KeyValuePair(“hash”,hash));
添加(新的KeyValuePair(“金额”,“20”));
添加(新的KeyValuePair(“卖方”),“mymail@mail.com"));
添加(新的KeyValuePair(“备注”、“付款”));
HttpFormUrlEncodedContent formContent=新的HttpFormUrlEncodedContent(值);
var内容=新的FormUrlEncodedContent(值);
Task t=客户端。PostAsync(“https://epay.com/api/“,内容);
t、 等待();
var响应=t.结果;
通过此操作,我得到如下错误消息:

无法指定类型或命名空间名称“HttpFormUrlEncodedContent” 找到(是否缺少using指令或程序集引用?)

解决这个问题的可能途径是什么

这是因为它来自
窗口​.网状物​.Http
命名空间,用于UWP应用程序

因此,如果您的程序实际上是一个UWP应用程序,那么请确保引用了所需的程序集,并使用为该命名空间添加

否则,只需将values集合添加到

,这是因为它来自
窗口​.网状物​.Http
命名空间,用于UWP应用程序

因此,如果您的程序实际上是一个UWP应用程序,那么请确保引用了所需的程序集,并使用
为该命名空间添加

否则,只需将values集合添加到

,这是因为它来自
窗口​.网状物​.Http是用于UWP应用程序的。这是因为它来自Windows​.网状物​.Http
,用于UWP应用程序。