110,499
社区成员
发帖
与我相关
我的任务
分享
System.Net.HttpWebRequest request;
request = (System.Net.HttpWebRequest)WebRequest.Create(url);
WebProxy pr = new WebProxy("124.40.121.3", 80);
pr.BypassProxyOnLocal = true;
pr.Credentials = CredentialCache.DefaultCredentials;
request.Proxy = pr;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
string encoding = "bg2312";
string returl = "http://app1.vote.cntv.cn/viewResult.jsp?voteId=12384";
string formhash = "69256b23";
string voteId = "12384";
string type = "html";
string items_1118821 = "131940";
string paraUrlCoded = "encoding=" + encoding + "&returl=" + returl + "&formhash=" + formhash + "&voteId=" + voteId + "&type=" + type + "&items_1118821=" + items_1118821;
byte[] payload;
payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
request.ContentLength = payload.Length;
Stream writer = request.GetRequestStream();
writer.Write(payload, 0, payload.Length);
writer.Close();
System.Net.HttpWebResponse response;
try
{
response = (System.Net.HttpWebResponse)request.GetResponse();
//问题就出在这里了 总是异常 说远程服务器返回错误 404未找到
//不用代理不报错 可以正常运行 用浏览器使用代理也正常
}
catch (Exception e)
{
return e.ToString();
}