Я пытаюсь войти на сайт, используя httpwebrequest post. Это работает отлично. Но когда я использую прокси для входа в систему, он не будет работать. Тайм -ауты подключения, и если я удалю часть: < /p>
request.Host="abc.com< /code> "; < /p>
Это снова работает хорошо с прокси, но выполнение вышеупомянутого запретит мне из входа в систему, так как сайт нуждается в этой информации. Как я могу превзойти эти предложения? HttpWebRequest httpWReq =
(HttpWebRequest)WebRequest.Create(url);
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = post;
byte[] data = encoding.GetBytes(postData);
string proxy = "58.20.127.26:3128";
/////byte[] data = GetBytes(postData);
WebProxy myProxy = new WebProxy(proxy);
httpWReq.Proxy = myProxy;
httpWReq.Method = "POST";
httpWReq.Accept = "text/html, application/xhtml+xml, */*";
httpWReq.Referer = refferr;
httpWReq.CookieContainer = yumCookies;
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.UserAgent = "xxxxxxxxxxx";
httpWReq.Host = "xxx.com";
httpWReq.Headers.Add("Accept-Language: en-US");
httpWReq.ContentLength = data.Length;
httpWReq.KeepAlive = true;
httpWReq.Headers.Add("Pragma: no-cache");
httpWReq.AllowAutoRedirect = true;
httpWReq.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
using (Stream stream = httpWReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream responseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(responseStream);
responseString = myStreamReader.ReadToEnd();
if (response.Cookies.Count > 0)
{
foreach (Cookie ck in response.Cookies)
{
yumCookies.Add(ck);
}
}
}
response.Close();
response = null;
response = null;
Подробнее здесь: https://stackoverflow.com/questions/234 ... st-c-sharp