• WebClient post data to .aspx page


     1WebClient client = new WebClient();
     2            client.Headers.Add("Accept""image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,application/x-shockwave-flash,application/vnd.ms-excel,application/vnd.ms-powerpoint,application/msword,*/*");
     3            client.Headers.Add("Accept-Language""zh-cn");
     4            client.Headers.Add("Accept-Encoding""gzip, deflate");
     5            client.Headers.Add("Content-Type""application/x-www-form-urlencoded");
     6
     7            string postString = "";
     8            postString += HttpUtility.UrlEncode("__VIEWSTATE");
     9            postString += "=";
    10            postString += HttpUtility.UrlEncode("/wEPDwUJNzM4ODg2MTUxZGRqlR5kSksCPGmgkbM/P3qjvjwnnQ");
    11            postString += "==";
    12            postString += "&";
    13            postString += HttpUtility.UrlEncode("TextBox1");
    14            postString += "=";
    15            postString += HttpUtility.UrlEncode("aa"); ;
    16            postString += "&";
    17            postString += HttpUtility.UrlEncode("Button2");
    18            postString += "=";
    19            postString += HttpUtility.UrlEncode("Post"); ;
    20            postString += "&";
    21            postString += HttpUtility.UrlEncode("__EVENTVALIDATION");
    22            postString += "=";
    23            postString += HttpUtility.UrlEncode("/wEWQALk4MLTCALs0bLrBgKM54rGBgLs0fbZDAK7q7GGCALs0Yq1BQLs0e58AuzRgtgJAuzRxsYPAuzR2qEIAuzR/rYIAuzRkpIBAqnU7OEDAqrU7OEDAqvU7OEDAqzU7OEDAq3U7OEDAq7U7OEDAq/U7OEDArDU7OEDAqHU7OEDAqLU7OEDAqnUsNAJAqrUsNAJAqvUsNAJAqzUsNAJAq3UsNAJAq7UsNAJAq/UsNAJArDUsNAJAqHUsNAJAqLUsNAJAqnUxKsCAqrUxKsCAqvUxKsCAqzUxKsCAq3UxKsCAq7UxKsCAq/UxKsCArDUxKsCAqHUxKsCAqLUxKsCAqnUqPMNAqrUqPMNAqvUqPMNAqzUqPMNAq3UqPMNAq7UqPMNAq/UqPMNArDUqPMNAqHUqPMNAqLUqPMNAqnUvM4GAqrUvM4GAqvUvM4GAqzUvM4GAq3UvM4GAq7UvM4GAq/UvM4GArDUvM4GAqHUvM4GAqLUvM4GAqnUgL0MAqrUgL0MgYFttUnbBLGCqjUjnWSejeI7wZc");
    24            postString += "=";
    25            byte[] postData = System.Text.Encoding.ASCII.GetBytes(postString);
    26            byte[] returnData = client.UploadData(formatUrl, "POST", postData);
    27            returnString = Encoding.Default.GetString(returnData);
    28
    29            //其中"__VIEWSTATE很重要;
  • 相关阅读:
    软工实践1816-第四次作业
    软工实践1816-第三次作业
    软工实践1816-第二次作业
    Alpha 冲刺 (3/10)
    Alpha 冲刺 (2/10)
    Alpha 冲刺 (1/10)
    福大软工 · 第七次作业
    福大软工 · 第八次作业(课堂实战)- 项目UML设计(团队)
    福大软工1816 · 第六次作业
    福大软工1816 · 第五次作业
  • 原文地址:https://www.cnblogs.com/xiaowy/p/769501.html
Copyright © 2020-2023  润新知