HttpWebRequest req=(HttpWebRequest)WebRequest.Create(url);
// сохраняю куки для следующих зпросов Get подхватывае, а post :(
// вернее они вроде есть, а сервер не видит
if (cookie == null)
{
req.CookieContainer = new CookieContainer();
cookie = req.CookieContainer;
}
else
req.CookieContainer = cookie;
req.Method="POST";
req.KeepAlive = false;
req.AllowWriteStreamBuffering = true;
req.SendChunked = true;
req.ContentType = "application/x-www-form-urlencoded";
// составляю строку из NameValueCollection (PostParams) (параметры перекодированы для запроса)
string post=string.Empty;
for(int i=0;i<PostParams.Count;i++)
{
if(post==string.Empty)
post=PostParams.GetKey(i)+"="+PostParams.Get(i);
else
post+="&"+PostParams.GetKey(i)+"="+PostParams.Get(i);
}
byte[] buffer=Encoding.UTF8.GetBytes(post);
req.ContentLength = buffer.Length;
Stream wstrem=req.GetRequestStream();
wstrem.Write(buffer,0,buffer.Length);
wstrem.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
Stream strem = res.GetResponseStream ();
StreamReader rstrem = new StreamReader (strem, Encoding.Default);
string reply=rstrem.ReadToEnd();
res.Close();rstrem.Close();