- class Program
- {
- public static HttpClient Client;
- static HttpResponseMessage response;
- static void Main(string[] args)
- {
- var httpClient = new HttpClient();
- string url = "http://127.0.0.1/Manager/Login.aspx";
- List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>();
- paramList.Add(new KeyValuePair<string, string>("Username", "123"));
- paramList.Add(new KeyValuePair<string, string>("Password", "456"));
- response = httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(paramList)).Result;
- string result = response.Content.ReadAsStringAsync().Result;
- paramList = new List<KeyValuePair<string, string>>();
- paramList.Add(new KeyValuePair<string, string>("PageIndex", "0"));
- paramList.Add(new KeyValuePair<string, string>("PageSize", "10"));
- url = "http://127.0.0.1/News/NewsList.aspx";
- response = httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(paramList)).Result;
- result = response.Content.ReadAsStringAsync().Result;
- Console.WriteLine(result);
- Console.Read();
- }
- }
.net framework 4.5 及其以上