.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 }  !

posted on 2014-02-27 14:56  都是脚本惹的祸  阅读(333)  评论(0编辑  收藏  举报

导航