.net Post数据到指定服务器
public string GetKeywordState(string keywords) { string url = Request.Url.Host; keywords = keywords.Length > 0 ? keywords.Substring(0, keywords.Length - 1) : ""; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(Tools.ConfigManager.GetString("GetKeywordStateHostUrl", "ShowWeb5")); client.DefaultRequestHeaders.Add("Authorization", "Basic " + Tools.Crypto.Encrypt(Tools.ConfigManager.GetString("ApiAuthorization", "ShowWeb5"))); HttpResponseMessage response = client.PostAsJsonAsync(Tools.ConfigManager.GetString("GetKeywordStateFullUrl", "ShowWeb5"), new { Url = url, Keywords = keywords }).Result; if (response.IsSuccessStatusCode) { var ss = response.Content.ReadAsStringAsync().Result; Console.WriteLine(ss); } return ""; }
new
{ Url = url, Keywords = keywords } !