Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to enable cookie in httpwebrequest ? c#

New BinaryNew Binary Member Posts: 3

CookieContainer c = new CookieContainer();
void getrespense(string link)
{
var request = (Requestionner)WebRequest.Create(link);
var data = Encoding.ASCII.GetBytes(string.Format("sf_url={0}&sf_submit=&new=1&lang=en&app=: undefined", textBox1.Text));
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.CookieContainer = c;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
c.Add(response.Cookies);
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
}

Comments

  • New BinaryNew Binary Member Posts: 3

    when post data to get respense I have this error Your request could not be served because you have browser cookies disabled. Please enable cookies in your browser's settings and try again I use firefox user agent

  • New BinaryNew Binary Member Posts: 3

    I test other user agent but the seme error

Sign In or Register to comment.