Alex

Alex

  • NA
  • 1
  • 0

How post message to forum

May 31 2009 8:04 AM
I try post message on forum and not have result: HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://forum.tomsk.ru/forum.php"); myHttpWebRequest.UserAgent = "Mozila/4.0 (compatible; MSIE 6.0;" +"Windows NT 5.1; SV1; MyIE2;"; myHttpWebRequest.Accept = "image/gif, image/x-xbitmap, image/jpeg," +"image/pjpeg, application/x-shockwave-flash," +"application/vnd.ms-excel," +"application/vnd.ms-powerpoint," +"application/msword, */*"; myHttpWebRequest.Headers.Add("Accept-Language", "ru"); HttpWebResponse myHttpWebResponse; myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); string sCookies = String.IsNullOrEmpty(myHttpWebResponse.Headers["Set-Cookie"]) ? "" : myHttpWebResponse.Headers["Set-Cookie"]; myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create( "http://forum.tomsk.ru/forum.php?a=10"); myHttpWebRequest.Method = WebRequestMethods.Http.Post; myHttpWebRequest.Referer = "http://forum.tomsk.ru/forum.php?a=9&g=28&t=1047536"; myHttpWebRequest.UserAgent =" Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"; myHttpWebRequest.Accept = "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, */*"; myHttpWebRequest.Headers.Add("Accept-Encoding: gzip, deflate"); myHttpWebRequest.Headers.Add("Accept-Language", "ru"); myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"; if (!String.IsNullOrEmpty(sCookies)) myHttpWebRequest.Headers.Add(HttpRequestHeader.Cookie, sCookies); myHttpWebRequest.AllowAutoRedirect = false; [code] string sQueryString = "creator=urgant&subject_name=hate&mess_text=dog&group_n=28&title_n=1047536"; byte[] ByteArr = System.Text.Encoding.Default.GetBytes(sQueryString); myHttpWebRequest.ContentLength = ByteArr.Length; myHttpWebRequest.GetRequestStream().Write(ByteArr, 0, ByteArr.Length); myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); StreamReader myStreamReader = new StreamReader(myHttpWebResponse.GetResponseStream(), Encoding.GetEncoding(1251)); string res = myStreamReader.ReadToEnd(); Console.WriteLine(res); Console.WriteLine("Please press key fr exit"); Console.ReadKey(); Please help me, I am begin programming and I am eleven years old

Answers (2)