Здравствуйте, возникла следующая проблема: делаю запрос к серверу через httpWebRequest
static void Main(string[] args)
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create(«www.google.ru/sorry/Captcha?continue=http%3A%2F%2Fwww.google.ru%2Fsearch%3Fq%3D%25D1%2581%25D0%25B5%25D0%25BE%25D0%25BF%25D1%2583%25D0%25BB%25D1%258C%25D1%2582%25D1%2583%25D1%2581%26channel%3Dlinkdoctor&id=10783499217868175628&captcha=2119579&submit=%D0%9E%D1%82%D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D1%82%D1%8C»);
httpWebRequest.AllowAutoRedirect = true;
httpWebRequest.CookieContainer = new CookieContainer();
if (Cooks != null)
{
httpWebRequest.CookieContainer.Add(Cooks);
}
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); httpWebResponse.Cookies = httpWebRequest.CookieContainer.GetCookies(httpWebRequest.RequestUri);
{
Cooks.Add(httpWebResponse.Cookies);
}
Stream stream = httpWebResponse.GetResponseStream();
if (stream != null)
var reader = new StreamReader(stream);
Console.Write(reader.ReadToEnd());
}
}
Возникает исключение и соединение закрывается.
Как можно проигнорировать ошибку и получить данные с сервера?
|
||||||||||||||||
|
|||||||||||
|
|||||||||||
Похожие вопросы |