我的 asp.net mvc web 应用程序中有以下 WebClient:
using (WebClient wc = new WebClient()) // call the Third Party API to get the account id
{
string url = currentURL + "resources/" + ResourceID + "/accounts?AUTHTOKEN=" + pmtoken;
var json = await wc.DownloadStringTaskAsync(url);
}
所以任何人都可以建议我如何将它从
WebClient
更改为HttpClient
?
HttpClient client = new HttpClient(); // actually only one object should be created by Application
string page = await client.GetStringAsync("page URL here");